[Haskell-cafe] Simple matrix

Atila Romero atilaromero at yahoo.com.br
Mon Jun 26 08:57:48 EDT 2006


Although there *could* be a fromInteger default behavior, there isn't a 
mathematical default behavior to c+A.
An even c*A it's hard to make work, because an identity matrix only 
works if it is a square matrix.
Example, if in c*A we make
A=
1 3
2 4
and
c=
c 0 0 0 ...
0 c 0 0 ...
0 0 c 0 ...
0 0 0 c ...
...
the result will have 2 lines and infinite columns. And if we make A*c 
the result will have 2 columns and infinite lines.
And since there's no way to tell to fromInteger which size we need for 
c, there's no way to make fromInteger works in a intuitive way.

So, I think it's better to just not use fromInteger at all, because it 
will work at some cases but will give wrong results at others.

Atila

Bjorn Lisper wrote:
> Udo Stenzel:
>   
>> Bjorn Lisper wrote:
>>     
>>> - your definition of fromInteger will behave strangely with the elementwise
>>>   extended operations, like (+). 1 + [[1,2],[3,4]] will become
>>>   [[2,2],[3,5]] rather than [[2,3],[4,5]]. Array languages supporting this
>>>   kind of overloading invariably have the second form of semantics.
>>>       
>> Don't call an array a matrix.  If is named matrix, it should have
>> matrix multiplication, addition, and they should obey the expected laws.  
>>     
>
> But you still have the problem with the overloading of constants in your
> proposal. If you write 17 + a, where a is a matrix, what do people in
> general expect it to be?
>
> Björn Lisper
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>   


		
_______________________________________________________ 
Yahoo! Acesso Grátis - Internet rápida e grátis. Instale 
o discador agora! 
http://br.acesso.yahoo.com


More information about the Haskell-Cafe mailing list