44 #ifndef GEN_MATRIX_CLASS_H
45 #define GEN_MATRIX_CLASS_H
58 namespace DenseLinAlgPack {
622 std::valarray<value_type>
v_;
664 #ifdef LINALGPACK_CHECK_SLICE_SETUP
666 throw std::length_error(
"Matrix must be square");
684 if(gms_lhs.
rows() == rows && gms_lhs.
cols() ==
cols)
return;
686 throw std::length_error(
"assert_gms_lhs(...): lhs DMatrixSlice dim does not match rhs dim");
748 gm_rhs->
resize(rows,cols);
766 #ifndef LINALGPACK_CHECK_RANGE
772 #ifndef LINALGPACK_CHECK_RANGE
778 #ifndef LINALGPACK_CHECK_SLICE_SETUP
788 : ptr_(0), max_rows_(0), rows_(0), cols_(0)
794 : ptr_(ptr), max_rows_(max_rows), rows_(rows), cols_(cols)
802 : ptr_( gms.col_ptr(1) + (I.lbound() - 1) + (J.lbound() - 1) * gms.max_rows() )
803 , max_rows_(gms.max_rows())
889 return DMatrixSlice(*
this, RangePack::full_range(I, 1,
rows()), RangePack::full_range(J,1,
cols()));
895 , RangePack::full_range(I, 1,
rows()), RangePack::full_range(J,1,
cols()) );
962 #ifndef LINALGPACK_CHECK_RANGE
968 #ifndef LINALGPACK_CHECK_RANGE
982 : v_(rows*cols), rows_(rows)
987 : v_(val,rows*cols), rows_(rows)
992 : v_(rows*cols), rows_(rows)
1012 v_.resize(rows*cols,val);
1041 return v_[(i-1) + (j-1) *
rows_];
1048 return (
const_cast<std::valarray<value_type>&
>(
v_))[(i-1) + (j-1) *
rows_];
1096 Range1D Ix = RangePack::full_range(I,1,
rows()), Jx = RangePack::full_range(J,1,
cols());
1104 Range1D Ix = RangePack::full_range(I,1,
rows()), Jx = RangePack::full_range(J,1,
cols());
1206 #endif // GEN_MATRIX_CLASS_H
Teuchos::Ordinal size_type
Typedef for the size type of elements that are used by the library.
void assert_gms_square(const DMatrixSlice &gms)
Assert a matrix is square and throws length_error if it is not (LINALGPACK_CHECK_SLICE_SETUP).
EOverLap overlap(const DMatrixSlice &gms) const
const DMatrixSlice * operator&() const
DVectorSlice row(DMatrixSlice &gms, BLAS_Cpp::Transp trans, size_type i)
DVectorSlice p_diag(difference_type k) const
value_type * col_ptr(size_type j)
DenseLinAlgPack::size_type size_type
void assign(DMatrix *gm_lhs, value_type alpha)
gm_lhs = alpha (elementwise)
size_type cols() const
Return the number of columns.
DVectorSlice diag(difference_type k=0)
DMatrixSlice * operator&()
Allow the address to be taken of an rvalue of this object.
Index size() const
Return the size of the range (ubound() - lbound() + 1)
ptrdiff_t difference_type
Index ubound() const
Return upper bound of the range.
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return rows of a possible transposed matrix.
VectorSliceTmpl< value_type > DVectorSlice
void assert_gms_sizes(const DMatrixSlice &gms1, BLAS_Cpp::Transp trans1, const DMatrixSlice &gms2, BLAS_Cpp::Transp trans2)
Assert two matrices are the same size and throws length_error if they are not (LINALGPACK_CHECK_RHS_S...
const value_type & const_reference
DVectorSlice p_diag(difference_type k) const
void validate_col_subscript(size_type j) const
DMatrixSlice & operator=(value_type alpha)
ptrdiff_t difference_type
DMatrixSlice operator()()
Return a DMatrixSlice that represents this entire matrix.
size_type max_rows() const
Return the number of rows in the full matrix. Equivalent to BLAS LDA argument.
DVectorSlice row(size_type i)
Return DVectorSlice object representing the ith row (1-based; 1,2,..,#this->rows()#) ...
. One-based subregion index range class.
void assert_gms_lhs(const DMatrixSlice &gms_lhs, size_type rows, size_type cols, BLAS_Cpp::Transp trans_rhs=BLAS_Cpp::no_trans)
void validate_col_subscript(size_type j) const
size_type rows() const
Return the number of rows.
const value_type & const_reference
void copy(const f_int &N, const f_dbl_prec *X, const f_int &INCX, f_dbl_prec *Y, const f_int &INCY)
DVectorSlice col(size_type j)
Return DVectorSlice object representing the jth column (1-based; 1,2,..,#this->cols()#) ...
value_type * col_ptr(size_type j)
size_type max_rows() const
Return the number of rows in the full matrix. Equivalent to BLAS LDA argument.
std::valarray< value_type > v_
DVectorSlice col(DMatrixSlice &gms, BLAS_Cpp::Transp trans, size_type j)
void resize(size_type rows, size_type cols, value_type val=value_type())
Resize matrix to a (rows x cols) matrix and initializes any added elements by val.
std::valarray< value_type > valarray
DMatrix & operator=(value_type rhs)
EOverLap
Enumeration for returning the amount of overlap between two objects.
void free()
frees memory and leaves a (0 x 0) matrix
DMatrix()
Construct a matrix with rows = cols = 0.
DenseLinAlgPack::size_type size_type
const f_dbl_prec const f_int const f_int const f_int f_dbl_prec rhs[]
Index lbound() const
Return lower bound of the range.
size_type rows() const
Return the number of rows.
DVectorSlice diag(difference_type k=0)
FortranTypes::f_dbl_prec value_type
Typedef for the value type of elements that is used for the library.
void swap(row_col_value_type< T > &v1, row_col_value_type< T > &v2)
Swap row_col_value_type<T> objects.
DMatrixSlice & operator()()
Return reference of this. Included for iniformity with DMatrix.
void resize_gm_lhs(DMatrix *gm_rhs, size_type rows, size_type cols, BLAS_Cpp::Transp trans_rhs)
Utility to resize a DMatrix to the size of a rhs matrix.
DenseLinAlgPack::value_type value_type
void validate_setup(size_type size) const
DenseLinAlgPack::DMatrixSlice DMatrixSlice
void validate_row_subscript(size_type i) const
EOverLap overlap(const DMatrixSlice &gms) const
DVectorSlice col(size_type j)
Return DVectorSlice object representing the jth column (1-based; 1,2,..,#this->cols()#, or throw std::out_of_range)
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return columns of a possible transposed matrix.
RangePack::Range1D Range1D
void bind(DMatrixSlice gms)
size_type cols() const
Return the number of columns.
void validate_row_subscript(size_type i) const
DenseLinAlgPack::value_type value_type
DVectorSlice row(size_type i)
Return DVectorSlice object representing the ith row (1-based; 1,2,..,#this->rows()#, or throw std::out_of_range)