On Tue, Apr 5, 2011 at 12:00 AM, pong <wypo...@gmail.com> wrote:
> By that I simply mean a function that on input a real matrix M returns
> the matrix N such that n[i][j] = abs(m[i][j]).
>
> This can be achieve by something like:
>
> n = len(M.rows()); m =len(M.columns()); N = matrix(n,m,lambda i,j:
> abs(M[i][j]));
A bit cleaner is:
sage: B = matrix(2,2,lambda i,j: i-j); B
[ 0 -1]
[ 1 0]
sage: B.apply_map(abs)
[0 1]
[1 0]
--Mike
I suppose this is because the determinant is sometimes written as
|1 0|
|0 -1|
but I think that's carrying things too far. I'd say this violates the Principle of Least Surprise...
I see two "bugs": that introspection claims that ".abs()" is defined in the file it claims:
=======================
sage: B.abs?
String Form: <built-in method abs of sage.matrix.matrix_integer_dense.Matrix_integer_dense object at 0x10ce3a4d0>
Namespace: Interactive
Definition: B.abs(self)
Docstring:
Return the absolute value of self. (This just calls the __abs__
method, so it is equivalent to the abs() built-in function.)
=======================
(which is not the case); and the use of "abs" (in any form) for determinant.
But that's just me.
Justin
--
Justin C. Walker
Curmudgeon-at-large
Director
Institute for the Absorption of Federal Funds
----
186,000 Miles per Second
Not just a good idea:
it's the law!
----