On Apr 4, 2011, at 15:19 , John H Palmieri wrote:

> On Monday, April 4, 2011 3:00:20 PM UTC-7, pong 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])); 
>> 
>> However, for a square matrix M, M.abs() returns something which wasn't 
>> what one expected: 
>> 
>> B = matrix(2,2,lambda i,j: i-j); B; B.abs() 
>> 
>> returns 
>> 
>> [ 0 -1] 
>> [ 1  0] 
>> 
>> and 1 
>> 
>> Is it a bug? Or something that I missed? 
>> 
> 
> For matrices, B.abs() returns the determinant.  If you type "B.abs?", you'll 
> see a message like
> 
>       Return the absolute value of self.  (This just calls the __abs__
>       method, so it is equivalent to the abs() built-in function.)
> 
> Then if you type "B.__abs__?", you'll see
> 
>       Synonym for self.determinant(...).

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!
----

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to