/** @file matrix.cpp
*
- * Implementation of symbolic matrices
- *
+ * Implementation of symbolic matrices */
+
+/*
* GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
#include <algorithm>
#include <stdexcept>
-#include "ginac.h"
+#include "matrix.h"
+#include "debugmsg.h"
+
+namespace GiNaC {
//////////
// default constructor, destructor, copy constructor, assignment operator
/** Default ctor. Initializes to 1 x 1-dimensional zero-matrix. */
matrix::matrix()
- : basic(TINFO_MATRIX), row(1), col(1)
+ : basic(TINFO_matrix), row(1), col(1)
{
debugmsg("matrix default constructor",LOGLEVEL_CONSTRUCT);
m.push_back(exZERO());
* @param r number of rows
* @param c number of cols */
matrix::matrix(int r, int c)
- : basic(TINFO_MATRIX), row(r), col(c)
+ : basic(TINFO_matrix), row(r), col(c)
{
debugmsg("matrix constructor from int,int",LOGLEVEL_CONSTRUCT);
m.resize(r*c, exZERO());
/** Ctor from representation, for internal use only. */
matrix::matrix(int r, int c, vector<ex> const & m2)
- : basic(TINFO_MATRIX), row(r), col(c), m(m2)
+ : basic(TINFO_matrix), row(r), col(c), m(m2)
{
debugmsg("matrix constructor from int,int,vector<ex>",LOGLEVEL_CONSTRUCT);
}
* itself or one of the elements 'has' it. */
bool matrix::has(ex const & other) const
{
- ASSERT(other.bp!=0);
+ GINAC_ASSERT(other.bp!=0);
// tautology: it is the expression itself
if (is_equal(*other.bp)) return true;
int matrix::compare_same_type(basic const & other) const
{
- ASSERT(is_exactly_of_type(other, matrix));
+ GINAC_ASSERT(is_exactly_of_type(other, matrix));
matrix const & o=static_cast<matrix &>(const_cast<basic &>(other));
// compare number of rows
* called internally by matrix::determinant(). */
ex determinant_numeric(const matrix & M)
{
- ASSERT(M.rows()==M.cols()); // cannot happen, just in case...
+ GINAC_ASSERT(M.rows()==M.cols()); // cannot happen, just in case...
matrix tmp(M);
ex det=exONE();
ex piv;
* routine is only called internally by matrix::determinant(). */
ex determinant_symbolic_perm(const matrix & M)
{
- ASSERT(M.rows()==M.cols()); // cannot happen, just in case...
+ GINAC_ASSERT(M.rows()==M.cols()); // cannot happen, just in case...
if (M.rows()==1) { // speed things up
return M(0,0);
* called internally by matrix::determinant(). */
ex determinant_symbolic_minor(const matrix & M)
{
- ASSERT(M.rows()==M.cols()); // cannot happen, just in case...
+ GINAC_ASSERT(M.rows()==M.cols()); // cannot happen, just in case...
if (M.rows()==1) { // end of recursion
return M(0,0);
* that are very hard to canonicalize. */
/*ex determinant_symbolic_leverrier(const matrix & M)
*{
- * ASSERT(M.rows()==M.cols()); // cannot happen, just in case...
+ * GINAC_ASSERT(M.rows()==M.cols()); // cannot happen, just in case...
*
* matrix B(M);
* matrix I(M.row, M.col);
}
*/
-#ifdef DOASSERT
+#ifdef DO_GINAC_ASSERT
// test if we really have an upper echelon matrix
int zero_in_last_row=-1;
for (int r=1; r<=m; ++r) {
break;
}
}
- ASSERT((zero_in_this_row>zero_in_last_row)||(zero_in_this_row=n));
+ GINAC_ASSERT((zero_in_this_row>zero_in_last_row)||(zero_in_this_row=n));
zero_in_last_row=zero_in_this_row;
}
-#endif // def DOASSERT
+#endif // def DO_GINAC_ASSERT
// assemble solution
matrix sol(n,1);
}
*/
-#ifdef DOASSERT
+#ifdef DO_GINAC_ASSERT
// test solution with echelon matrix
for (int r=1; r<=m; ++r) {
ex e=0;
cout << "b.ffe_get(" << r<<",1)=" << b.ffe_get(r,1) << endl;
cout << "diff=" << (e-b.ffe_get(r,1)).normal() << endl;
}
- ASSERT((e-b.ffe_get(r,1)).normal().is_zero());
+ GINAC_ASSERT((e-b.ffe_get(r,1)).normal().is_zero());
}
// test solution with original matrix
ex xxx=e-rhs.ffe_get(r,1);
cerr << "xxx=" << xxx << endl << endl;
}
- ASSERT((e-rhs.ffe_get(r,1)).normal().is_zero());
+ GINAC_ASSERT((e-rhs.ffe_get(r,1)).normal().is_zero());
}
-#endif // def DOASSERT
+#endif // def DO_GINAC_ASSERT
return sol;
}
const matrix some_matrix;
type_info const & typeid_matrix=typeid(some_matrix);
+
+} // namespace GiNaC