在FLENS我想实现“自定义”存储(也就是说,能够提供指向实际数据的指针并负责存储的内存管理)。FLENS的自定义存储
管理其缓冲器A矩阵的定义如下,例如:
typedef flens::GeMatrix<flens::FullStorage<double, flens::ColMajor> > M;
后来,人们可以使用像这样的矩阵:
M m1;
M m2;
M m3;
/* initialise the matrices */
m3 = m1 * m2;
为了做同样的事情与基质类型,它允许访问内部缓冲区,例如,GhostStorage
只是实现了FullStorage的方式,并增加了一个init()
方法,该方法允许设置内部指针(完整实现过长,无法粘贴这里):
void
init(IndexType numRows, IndexType numCols,
IndexType firstRow = I::defaultIndexBase,
IndexType firstCol = I::defaultIndexBase,
ElementType *p_data = NULL)
{
_data = p_data;
_numRows = numRows;
_numCols = numCols;
_firstRow = firstRow;
_firstCol = firstCol;
ASSERT(_numRows>=0);
ASSERT(_numCols>=0);
}
定义这样的类型后:
typedef flens::GhostStorage<double, flens::ColMajor> GhostEng;
class MGhost : public flens::GeMatrix<GhostEng>
{
public:
void
init(IndexType numRows, IndexType numCols,
IndexType firstRow,
IndexType firstCol,
ElementType *p_data = NULL)
{
engine().init(numRows,numCols,firstRow,firstCol,p_data);
}
};
我期望与上述同样的操作应该是可能的:
MGhost mg1;
MGhost mg2;
MGhost mg3;
/* initialise the matrices using the init() method */
mg3 = mg1 * mg2;
但是编译器在这种情况下抱怨:
没有已知的ar转换gument 1从 '常量 flens :: MatrixClosure>, flens :: GeMatrix>>' 到 '常量MGhost &'
FLENS作者提供指导有关implementing your custom type of matrix,但我使用已定义的矩阵式在这里 - flens::GeMatrix。
底线,问题是:如何在FLENS中实现一个矩阵,允许操纵内部缓冲区和高层交互,如m3 = m1 * m2
?
你好,杰克,谢谢你的回答。我发布这个问题已经有一段时间了。我会研究它,并在那个时候将你的答案标记为正确答案(或不答题)。信息+1。 – 2013-12-16 14:58:50