36 #ifndef MAT_MATRIXBASE
37 #define MAT_MATRIXBASE
46 template<
typename Treal,
typename Tmatrix>
48 template<
typename Treal,
typename Tmatrix>
49 class MatrixSymmetric;
50 template<
typename Treal,
typename Tmatrix>
51 class MatrixTriangular;
52 template<
typename Treal,
typename Tvector>
66 template<
typename Treal,
typename Tmatrix>
111 throw Failure(
"MatrixBase::operator== only implemented for k == 0");
131 this->
matrixPtr->write_to_buffer_count(ib_length, vb_length);
132 n_bytes = vb_length *
sizeof(Treal) + ib_length *
sizeof(
int);
176 if (mt.A.matrixPtr.haveDataStructureGet()) {
204 std::vector<int>
const & permutation,
205 std::vector<int> & newIndex) {
206 newIndex.resize(index.size());
207 for (
unsigned int i = 0; i < index.size(); ++i)
208 newIndex[i] = permutation[index[i]];
217 template<
typename Treal,
typename Tmatrix>
221 int type = (int)mattype;
222 file.write((
char*)&type,
sizeof(
int));
229 matrixPtr->writeToFile(file);
232 template<
typename Treal,
typename Tmatrix>
236 char type[
sizeof(int)];
237 file.read(type,
sizeof(
int));
238 if (((
int)*type) != mattype)
239 throw Failure(
"MatrixBase<Treal, Tmatrix>::"
240 "readFromFile(std::ifstream &, "
241 "matrix_type const): Wrong matrix type");
245 matrixPtr->readFromFile(file);
250 template<
typename Treal,
typename Tmatrix>
257 this->matrixPtr->write_to_buffer_count(ib_length, vb_length);
259 (
int)(vb_length *
sizeof(Treal) + ib_length *
sizeof(
int))) {
260 int* int_buf = (
int*)buffer;
261 int_buf[0] = mattype;
262 int_buf[1] = ib_length;
263 int_buf[2] = vb_length;
264 Treal* value_buf = (Treal*)&(int_buf[ib_length]);
268 this->matrixPtr->write_to_buffer(&int_buf[3], ib_length - 3,
269 value_buf, vb_length,
273 throw Failure(
"MatrixBase::write_to_buffer: Buffer is too small");
277 template<
typename Treal,
typename Tmatrix>
281 int* int_buf = (
int*)buffer;
282 if(int_buf[0] == mattype) {
283 int ib_length = int_buf[1];
284 int vb_length = int_buf[2];
287 Treal* value_buf = (Treal*)&(int_buf[ib_length]);
288 this->matrixPtr->read_from_buffer(&int_buf[3], ib_length - 3,
289 value_buf, vb_length,
293 throw Failure(
"MatrixBase::read_from_buffer: Wrong matrix type");