Skip to content
Snippets Groups Projects
Commit 0df4a832 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

bindings for fullMatrix::print and add fullMatrix::setAsShapeProxy

parent dcc21375
No related branches found
No related tags found
No related merge requests found
......@@ -311,6 +311,9 @@ void fullMatrix<double>::registerBindings(binding *b)
cm = cb->addMethod("gemm_naive", &fullMatrix<double>::gemm_naive);
cm->setArgNames("A","B","alpha","beta",NULL);
cm->setDescription("this = beta*this + alpha * (A.B)");
cm = cb->addMethod("print", &fullMatrix<double>::print);
cm->setArgNames("name",NULL);
cm->setDescription("print the matrix");
cm = cb->setConstructor<fullMatrix<double>,int,int>();
cm->setDescription ("A new matrix of size 'nRows' x 'nColumns'");
cm->setArgNames("nRows","nColumns",NULL);
......
......@@ -164,6 +164,17 @@ class fullMatrix
_own_data = false;
_data = original._data + c_start * _r;
}
void setAsShapeProxy(fullMatrix<scalar> &original, int nbRow, int nbCol)
{
if(_data && _own_data)
delete [] _data;
_c = nbCol;
_r = nbRow;
if(_c*_r != original._c*original._r)
Msg::Error("trying to reshape a fullMatrix without conserving the total number of entries");
_own_data = false;
_data = original._data;
}
inline int size1() const { return _r; }
inline int size2() const { return _c; }
fullMatrix<scalar> & operator = (const fullMatrix<scalar> &other)
......@@ -356,9 +367,9 @@ class fullMatrix
}
#endif
;
void print(const char *name="") const
void print(const std::string name = "") const
{
printf("Printing matrix %s:\n", name);
printf("Printing matrix %s:\n", name.c_str());
int ni = size1();
int nj = size2();
for(int I = 0; I < ni; I++){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment