*/
#include <iostream>
-
+#include <vector>
#include "DoubleTab.hxx"
class GenericMatrix
*/
int getNumberOfColumns ( void ) const ;
- const DoubleTab& getValues( void ) const ;
-
- DoubleTab getValues( void ) ;
-
- void setValues(const DoubleTab& values) ;
-
virtual double operator ()( int i, int j ) const = 0;
- double max() const;
-
- double min() const;
-
virtual bool isSymmetric(double tol=1e-6) const ;
bool isSquare() const ;
virtual bool containsPetscMatrix() const { return false; };
- int coefficient(int index) const ;
-
void view() const ;
protected: //----------------------------------------------------------------
bool _isSparseMatrix ;
- DoubleTab _values ;
};
#endif /* GENERICMATRIX_HXX_ */
*/
virtual ~Matrix ( void ) ;
+ const DoubleTab& getValues( void ) const ;
+
+ DoubleTab getValues( void ) ;
+
+ void setValues(const DoubleTab& values) ;
+
+ //returns the array of matrix coefficients
+ std::vector< double > getArray();
+
+ //returns the maximum coefficient
+ double max() const;
+
+ //returns the minimum coefficient
+ double min() const;
+
bool isSparseMatrix( void ) const ;
double& operator () ( int i, int j ) ;
friend std::ostream& operator<<(std::ostream& out, const Matrix& matrix ) ;
+
+ protected: //----------------------------------------------------------------
+
+ DoubleTab _values ;
+
+ //This function is used in the computation of the determinant
+ int coefficient(int index) const ;
};
#endif /* MATRIX_HXX_ */
*/
#include <math.h>
+#include <cstring>
#include "GenericMatrix.hxx"
#include "CdmathException.hxx"
return _numberOfColumns ;
}
-const DoubleTab&
-GenericMatrix::getValues( void ) const
-{
- return _values;
-}
-
-//----------------------------------------------------------------------
-DoubleTab
-GenericMatrix::getValues()
-//----------------------------------------------------------------------
-{
- return _values;
-}
-
-void
-GenericMatrix::setValues(const DoubleTab& values)
-{
- _values=values;
-}
-
bool
GenericMatrix::isSymmetric(double tol) const
{
return false;
}
-int
-GenericMatrix::coefficient(int index) const
-{
- if(! (index % 2) )
- return (1);
- return (-1);
-}
-
-
-double
-GenericMatrix::max() const
-{
- return _values.max();
-}
-
-
-double
-GenericMatrix::min() const
-{
- return _values.max();
-}
-
-
void
GenericMatrix::view() const
{
* Authors: CDMATH
*/
#include <iostream>
+#include <cstring>
#include "Matrix.hxx"
#include "Vector.hxx"
_values=DoubleTab (_numberOfRows*_numberOfColumns,matrix.getValues().getValues());
}
+const DoubleTab&
+Matrix::getValues( void ) const
+{
+ return _values;
+}
+
+//----------------------------------------------------------------------
+DoubleTab
+Matrix::getValues()
+//----------------------------------------------------------------------
+{
+ return _values;
+}
+
+void
+Matrix::setValues(const DoubleTab& values)
+{
+ _values=values;
+}
+
+double
+Matrix::max() const
+{
+ return _values.max();
+}
+
+double
+Matrix::min() const
+{
+ return _values.max();
+}
+
+std::vector< double >
+Matrix::getArray()
+{
+ int numberOfRows =getNumberOfRows();
+ int numberOfColums=getNumberOfColumns();
+ int size=_numberOfRows*numberOfColums;
+
+ vector< double > result(size);
+ double* values = result.data();
+
+ memcpy(values,_values.getPointer(),size*sizeof(double)) ;
+
+ return result;
+}
+
bool
Matrix::isSparseMatrix( void ) const
{
return res;
}
+int
+Matrix::coefficient(int index) const
+{
+ if(! (index % 2) )
+ return (1);
+ return (-1);
+}
+
double
Matrix::determinant() const
{