On Sat, Dec 12, 2009 at 11:09 PM, Minh Nguyen <[email protected]> wrote:
> Hi David,
>
> On Sun, Dec 13, 2009 at 11:20 AM, David Joyner <[email protected]> wrote:
>
> <SNIP>
>
>> I think this would fit nicely in the constructions document.
>> Adding an example of how to use map for Sage matrices might
>> be worth thinking about.
>
> I have provided some examples on using lambda and map() to construct matrices.
>


Nice examples, thanks.


>
>> I think one person asked me about that
>> recently and it would have been nice to point them to something.
>
> Do you still remember the question? I don't know what's required so
> the matrix examples are rather simple.


Here is a related non-example, which tries to create ain integer
(-1,1) matrix from a GF(2) matrix in the (wrong but) obvious way:

sage: A = random_matrix(GF(2), 2, 3)
sage: A

[0 1 1]
[0 1 0]
sage: f = lambda x: 2*ZZ(x)-1
sage: map(f,A)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)


One right way is to use the list of elements:


sage: A = random_matrix(GF(2), 2, 3); A

[0 1 0]
[0 0 1]
sage: f = lambda x: 2*ZZ(x)-1
sage: B = matrix(ZZ, 2, 3, map(f, A.list())); B

[-1  1 -1]
[-1 -1  1]


The actual question I don't remember exactly.
But we were arguing about matlab vs Sage.

Going form a vague memory:
My colleague was arguing that one should not teach
a course in scientific programming using Sage
because it was so slow in doing some very simple
things. Apparently if A is a vector or matrix in matlab
(ie, an array or real numbers) and f is a function
(eg, a sin or a polynomial), then f(A) is both
easy for the student to write and also super
optimized. He doubted Sage could do that.
So for large sized arrays with thousands of entries,
matlab would leave Sage in the dust.

My only argument, if I remember, was that his
argument did not make intuitive sense. I said that
though I didn't know off the top of my head
how to write down the evaluation of a function
on a matrix in an optimized way, there must exist one.
With scipy used in industry for serious number-crunching,
it must be possible.

Of course an example would be more convincing that
an existence argument:-) An example which would be
both easy for the student to perform (and also fast) would be
nice,


>
> --
> Regards
> Minh Van Nguyen
>
> --
> To post to this group, send an email to [email protected]
> To unsubscribe from this group, send an email to 
> [email protected]
> For more options, visit this group at 
> http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>

-- 
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to