25 #include <QtCore/QString>
48 for (i=0,w=
B_; i<
NCol_; i++,w++)
55 for (i=0,w=
B_; i<
NCol_; i++,w++)
59 for (w=
B_,q=M.
B_,i=0; i<
NCol_; i++,w++,q++)
60 memcpy((
void*)(*w), (
const void*)(*q),
NRow_*
sizeof(
double));
76 double *v=V.
B_, *r=R.
B_;
77 unsigned int N=std::min(M.
NCol_, V.
N_), i, l;
81 std::cout <<
"WARNING: SgVector operator*(const SgMatrix&, const SgVector&):"
82 <<
" incompatible ranges of the matrix and the vector\n";
85 for (i=0; i<R.
N_; i++,r++)
86 for (*r=0.0,v=V.
B_,l=0; l<N; l++,v++)
87 *r += *(*(M.
B_+l)+i)**v;
98 std::cerr <<
"WARNING: SgMatrix calcProduct_mat_x_mat(const SgMatrix& M1, "
99 <<
"const SgMatrix& M2): matrix size mismatch.\n";
102 unsigned int N=std::min(M1.
nCol(), M2.
nRow()), i, j, l;
103 unsigned int NRow=M1.
nRow(), NCol=M2.
nCol();
115 for (j=0; j<NCol; j++)
116 for (i=0; i<NRow; i++)
135 std::cerr <<
"WARNING: SgMatrix matT_x_mat(const SgMatrix&, const SgMatrix&):"
136 <<
" matrix size mismatch\n";
139 unsigned int N=std::min(M1.
nRow(), M2.
nRow()), i, j, l;
140 unsigned int NRow=M1.
nCol(), NCol=M2.
nCol();
151 for (j=0; j<NCol; j++)
152 for (i=0; i<NRow; i++)
169 std::cerr <<
"WARNING: SgMatrix mat_x_matT(const SgMatrix&, const SgMatrix&):"
170 <<
" matrix size mismatch\n";
173 unsigned int N=std::min(M1.
nCol(), M2.
nCol()), i, j, l;
174 unsigned int NRow=M1.
nRow(), NCol=M2.
nRow();
178 for (j=0; j<NCol; j++)
179 for (i=0; i<NRow; i++)
196 std::cout <<
"WARNING: SgVector matT_x_vec(const SgMatrix&, const SgVector&):"
197 <<
" incompatible ranges of the matrix and the vector\n";
200 unsigned int N=std::min(M.
nRow(), V.
n()), i, l;
201 unsigned int NRow=M.
nCol();
211 for (i=0; i<NRow; i++)
230 unsigned int i, j, NRow=M.
nRow(), NCol=M.
nCol();
234 for (i=0; i<NRow; i++)
237 for (j=0; j<NCol; j++)
238 s <<
" " << qPrintable(str.sprintf(
"%12.5e", M.
getElement(i,j))) <<
" ";
244 for (j=0; j<NCol; j++)
245 for (i=0; i<NRow; i++)
246 s << i <<
" " << j <<
" " << M.
getElement(i,j) <<
"\n";
SgMatrix calcProduct_mat_x_matT(const SgMatrix &M1, const SgMatrix &M2)
SgVector calcProduct_matT_x_vec(const SgMatrix &M, const SgVector &V)
std::ostream & operator<<(std::ostream &s, const SgMatrix &M)
SgVector operator*(const SgMatrix &M, const SgVector &V)
SgMatrix calcProduct_matT_x_mat(const SgMatrix &M1, const SgMatrix &M2)
SgMatrix calcProduct_mat_x_mat(const SgMatrix &M1, const SgMatrix &M2)
unsigned int NCol_
An number of columns in a matrix.
unsigned int nRow() const
SgMatrix & operator=(const SgMatrix &M)
void setElement(unsigned int i, unsigned int j, double d)
double getElement(unsigned int i, unsigned int j) const
double ** B_
A pointer on a pointer of a first element of the matrix.
unsigned int nCol() const
unsigned int NRow_
An number of rows in a matrix.
double * B_
A pointer on a first element of the vector.
void setElement(unsigned int i, double d)
double getElement(unsigned int i) const
unsigned int N_
An number of elements in a vector (dimension).