// public
/** Default ctor. Initializes to 1 x 1-dimensional zero-matrix. */
-matrix::matrix()
- : inherited(TINFO_matrix), row(1), col(1)
+matrix::matrix() : inherited(TINFO_matrix), row(1), col(1)
{
debugmsg("matrix default constructor",LOGLEVEL_CONSTRUCT);
m.push_back(_ex0());
matrix::~matrix()
{
debugmsg("matrix destructor",LOGLEVEL_DESTRUCT);
+ destroy(false);
}
matrix::matrix(const matrix & other)
{
debugmsg("matrix operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
* @param r number of rows
* @param c number of cols */
matrix::matrix(unsigned r, unsigned c)
- : inherited(TINFO_matrix), row(r), col(c)
+ : inherited(TINFO_matrix), row(r), col(c)
{
debugmsg("matrix constructor from unsigned,unsigned",LOGLEVEL_CONSTRUCT);
m.resize(r*c, _ex0());
/** Ctor from representation, for internal use only. */
matrix::matrix(unsigned r, unsigned c, const exvector & m2)
- : inherited(TINFO_matrix), row(r), col(c), m(m2)
+ : inherited(TINFO_matrix), row(r), col(c), m(m2)
{
debugmsg("matrix constructor from unsigned,unsigned,exvector",LOGLEVEL_CONSTRUCT);
}
* @exception range_error (index out of range) */
const ex & matrix::operator() (unsigned ro, unsigned co) const
{
- if (ro<0 || ro>=row || co<0 || co>=col)
+ if (ro>=row || co>=col)
throw (std::range_error("matrix::operator(): index out of range"));
return m[ro*col+co];
* @exception range_error (index out of range) */
matrix & matrix::set(unsigned ro, unsigned co, ex value)
{
- if (ro<0 || ro>=row || co<0 || co>=col)
+ if (ro>=row || co>=col)
throw (std::range_error("matrix::set(): index out of range"));
-
+
ensure_if_modifiable();
m[ro*col+co] = value;
return *this;
return (m[0]*m[3]-m[2]*m[1]).expand();
if (n==3)
return (m[0]*m[4]*m[8]-m[0]*m[5]*m[7]-
- m[1]*m[3]*m[8]+m[2]*m[3]*m[7]+
- m[1]*m[5]*m[6]-m[2]*m[4]*m[6]).expand();
+ m[1]*m[3]*m[8]+m[2]*m[3]*m[7]+
+ m[1]*m[5]*m[6]-m[2]*m[4]*m[6]).expand();
// This algorithm can best be understood by looking at a naive
// implementation of Laplace-expansion, like this one:
for (unsigned r2=r0+1; r2<m; ++r2) {
for (unsigned c=r1+1; c<n; ++c) {
dividend_n = (tmp_n.m[r0*n+r1]*tmp_n.m[r2*n+c]*
- tmp_d.m[r2*n+r1]*tmp_d.m[r0*n+c]
- -tmp_n.m[r2*n+r1]*tmp_n.m[r0*n+c]*
- tmp_d.m[r0*n+r1]*tmp_d.m[r2*n+c]).expand();
+ tmp_d.m[r2*n+r1]*tmp_d.m[r0*n+c]
+ -tmp_n.m[r2*n+r1]*tmp_n.m[r0*n+c]*
+ tmp_d.m[r0*n+r1]*tmp_d.m[r2*n+c]).expand();
dividend_d = (tmp_d.m[r2*n+r1]*tmp_d.m[r0*n+c]*
- tmp_d.m[r0*n+r1]*tmp_d.m[r2*n+c]).expand();
+ tmp_d.m[r0*n+r1]*tmp_d.m[r2*n+c]).expand();
bool check = divide(dividend_n, divisor_n,
- tmp_n.m[r2*n+c], true);
+ tmp_n.m[r2*n+c], true);
check &= divide(dividend_d, divisor_d,
- tmp_d.m[r2*n+c], true);
+ tmp_d.m[r2*n+c], true);
GINAC_ASSERT(check);
}
// fill up left hand side with zeros
//////////
const matrix some_matrix;
-const type_info & typeid_matrix=typeid(some_matrix);
+const std::type_info & typeid_matrix = typeid(some_matrix);
#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC