dynare/dynare++/sylv/testing/MMMatrix.hh

72 lines
1.2 KiB
C++
Raw Normal View History

/* $Header: /var/lib/cvs/dynare_cpp/sylv/testing/MMMatrix.h,v 1.1.1.1 2004/06/04 13:01:13 kamenik Exp $ */
/* Tag $Name: $ */
#ifndef MM_MATRIX_H
#define MM_MATRIX_H
#include "GeneralMatrix.hh"
#include "SylvMemory.hh"
#include <string>
#include <utility>
#include <memory>
using namespace std;
2017-05-16 16:30:27 +02:00
class MMException : public MallocAllocator
{
string message;
public:
MMException(string mes) : message(std::move(mes))
2017-05-16 16:30:27 +02:00
{
}
MMException(const char *mes) : message(mes)
{
}
const char *
getMessage() const
{
return message.data();
}
};
2017-05-16 16:30:27 +02:00
class MMMatrixIn : public MallocAllocator
{
std::shared_ptr<const double> data;
2017-05-16 16:30:27 +02:00
int rows;
int cols;
public:
2017-05-16 16:30:27 +02:00
MMMatrixIn(const char *fname);
~MMMatrixIn() = default;
ConstVector
2017-05-16 16:30:27 +02:00
getData() const
{
return ConstVector{data, size()};
2017-05-16 16:30:27 +02:00
}
int
size() const
{
return rows*cols;
}
int
row() const
{
return rows;
}
int
col() const
{
return cols;
}
};
2017-05-16 16:30:27 +02:00
class MMMatrixOut : public MallocAllocator
{
public:
2017-05-16 16:30:27 +02:00
static void write(const char *fname, int rows, int cols, const double *data);
static void write(const char *fname, const GeneralMatrix &m);
};
#endif /* MM_MATRIX_H */