* New upstream release; binary incompatible, so it's libginac1.4 now.
* debian/*: Streamlining by Peter Eisentraut <petere@debian.org>.
- -- Richard Kreckel <kreckel@ginac.de> <DATE>
+ -- Richard Kreckel <kreckel@ginac.de> Mon, 17 Apr 2006 22:25:48 +0200
ginac (1.3.4-1) unstable; urgency=low
@}
@end example
+@cindex @code{is_zero_matrix()}
+The method @code{matrix::is_zero_matrix()} returns @code{true} only if
+all entries of the matrix are zeros. There is also method
+@code{ex::is_zero_matrix()} which returns @code{true} only if the
+expression is zero or a zero matrix.
+
@cindex @code{transpose()}
There are three ways to do arithmetic with matrices. The first (and most
direct one) is to use the methods provided by the @code{matrix} class:
the matrix @samp{M = [[a, b], [c, d]]}. The parameter @code{G} defines
the metric of the surrounding (pseudo-)Euclidean space. This can be an
indexed object, tensormetric, matrix or a Clifford unit, in the later
-case the optional parameters @code{rl} and @code{anticommuting} are ignored
-even if supplied. The returned value of this function is a list of
-components of the resulting vector.
+case the optional parameters @code{rl} and @code{anticommuting} are
+ignored even if supplied. Depending from the type of @code{v} the
+returned value of this function is either a vector or a list holding vector's
+components.
@cindex @code{clifford_max_label()}
Finally the function
@end example
for checking whether one expression is equal to another, or equal to zero,
-respectively.
+respectively. See also the method @code{ex::is_zero_matrix()},
+@pxref{Matrices}.
@subsection Ordering expressions
pointer_to_map_function fcn(canonicalize_clifford);
if (is_a<matrix>(e_) // || is_a<pseries>(e) || is_a<integral>(e)
- || is_a<lst>(e_)) {
+ || e_.info(info_flags::list)) {
return e_.map(fcn);
} else {
ex e=simplify_indexed(e_);
if (is_a<clifford>(e) && is_a<cliffordunit>(e.op(0))) {
return -e;
} else if (is_a<add>(e) || is_a<ncmul>(e) || is_a<mul>(e) //|| is_a<pseries>(e) || is_a<integral>(e)
- || is_a<matrix>(e) || is_a<lst>(e)) {
+ || is_a<matrix>(e) || e.info(info_flags::list)) {
return e.map(fcn);
} else if (is_a<power>(e)) {
return pow(clifford_prime(e.op(0)), e.op(1));
else
throw(std::invalid_argument("remove_dirac_ONE(): expression is a non-scalar Clifford number!"));
} else if (is_a<add>(e1) || is_a<ncmul>(e1) || is_a<mul>(e1)
- || is_a<matrix>(e1) || is_a<lst>(e1)) {
+ || is_a<matrix>(e1) || e1.info(info_flags::list)) {
if (options & 3) // is a child or was already expanded
return e1.map(fcn);
else
else
throw(std::invalid_argument("lst_to_clifford(): dimensions of vector and clifford unit mismatch"));
} else
- throw(std::invalid_argument("lst_to_clifford(): first argument should be a vector vector"));
- } else if (is_a<lst>(v)) {
+ throw(std::invalid_argument("lst_to_clifford(): first argument should be a vector (nx1 or 1xn matrix)"));
+ } else if (v.info(info_flags::list)) {
if (dim == ex_to<lst>(v).nops())
return indexed(matrix(dim, 1, ex_to<lst>(v)), ex_to<varidx>(mu).toggle_variance()) * e;
else
pointer_to_map_function_1arg<const ex &> fcn(get_clifford_comp, c);
int ival = ex_to<numeric>(ex_to<varidx>(c.op(1)).get_value()).to_int();
- if (is_a<add>(e) || is_a<lst>(e) // || is_a<pseries>(e) || is_a<integral>(e)
+ if (is_a<add>(e) || e.info(info_flags::list) // || is_a<pseries>(e) || is_a<integral>(e)
|| is_a<matrix>(e))
return e.map(fcn);
else if (is_a<ncmul>(e) || is_a<mul>(e)) {
{
ex x, D, cu;
- if (! is_a<matrix>(v) && ! is_a<lst>(v))
+ if (! is_a<matrix>(v) && ! v.info(info_flags::list))
throw(std::invalid_argument("clifford_moebius_map(): parameter v should be either vector or list"));
if (is_a<clifford>(G)) {
}
x = lst_to_clifford(v, cu);
- ex e = simplify_indexed(canonicalize_clifford((a * x + b) * clifford_inverse(c * x + d)));
- return clifford_to_lst(e, cu, false);
+ ex e = clifford_to_lst(simplify_indexed(canonicalize_clifford((a * x + b) * clifford_inverse(c * x + d))), cu, false);
+ return (is_a<matrix>(v) ? matrix(ex_to<matrix>(v).rows(), ex_to<matrix>(v).cols(), ex_to<lst>(e)) : e);
}
ex clifford_moebius_map(const ex & M, const ex & v, const ex & G, unsigned char rl, bool anticommuting)
#include "mul.h"
#include "ncmul.h"
#include "numeric.h"
+#include "matrix.h"
#include "power.h"
#include "lst.h"
#include "relational.h"
return bp->is_polynomial(vars);
}
+/** Check whether expression is zero or zero matrix. */
+bool ex::is_zero_matrix() const
+{
+ if (is_zero())
+ return true;
+ else {
+ ex e = evalm();
+ return is_a<matrix>(e) && ex_to<matrix>(e).is_zero_matrix();
+ }
+}
+
// private
/** Make this ex writable (if more than one ex handle the same basic) by
int compare(const ex & other) const;
bool is_equal(const ex & other) const;
bool is_zero() const { extern const ex _ex0; return is_equal(_ex0); }
+ bool is_zero_matrix() const;
// symmetry
ex symmetrize() const;
return k;
}
+/** Function to check that all elements of the matrix are zero.
+ */
+bool matrix::is_zero_matrix() const
+{
+ for (exvector::const_iterator i=m.begin(); i!=m.end(); ++i)
+ if(!(i->is_zero()))
+ return false;
+ return true;
+}
+
ex lst_to_matrix(const lst & l)
{
lst::const_iterator itr, itc;
matrix solve(const matrix & vars, const matrix & rhs,
unsigned algo = solve_algo::automatic) const;
unsigned rank() const;
+ bool is_zero_matrix() const;
protected:
ex determinant_minor() const;
int gauss_elimination(const bool det = false);