[Haskell-cafe] matrix computations based on the GSL
Keean Schupke
k.schupke at imperial.ac.uk
Fri Jul 8 13:08:21 EDT 2005
Henning Thielemann wrote:
>On Fri, 8 Jul 2005, Keean Schupke wrote:
>
>
>
>>So the linear operator is translation (ie: + v)... effectively 'plus'
>>could be viewed as a function which takes a vector and returns a matrix
>>(operator)
>>
>> (+) :: Vector -> Matrix
>>
>>
>
>Since a matrix _is_ not a linear map but only its representation, this
>would not make sense. As I said (v+) is not a linear map thus there is no
>matrix which represents it. A linear map f must fulfill
> f 0 == 0
>
>But since
> v+0 == v
> the function (v+) is only a linear map if 'v' is zero.
>
> I can't see how to fit in your vector extension by the 1-component.
>
>
>
Eh?
Translation is a linear operation no? Adding vectors translates the
first by the second
(or the second by the first - the two are isomorphic)... A translation
can be represented
by the matrix:
1 0 0 0
0 1 0 0
0 0 1 0
dx dy dz 1
So the result of "v+" is this matrix.
In other words this matrix is the 'vector addition operator'...
providing you pad the vectors
with an additional '1' at the end.
So if:
translate :: Vector -> Matrix
[x,y,z,1] = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[x,y,z,1]]
we can create a matrix representing translation from:
translate [3,4,5,1]
and can apply this translation to another vector:
mapply (translate [3,4,5,1]) [2,3,4,1] = [5,7,9,1]
All I was saying is that following this, partial application of vector
addition:
[3,4,5] + [2,3,4] = [5,7,9]
but partially applying:
([3,4,5] +)
would be a the matrix defined above as (translate [3,4,5,1]) ... Of
course this has the
drawback that you need an extra dimension in you vectors and matrices to
cope with
translation.
Anyway I have more or less convinced myself that separating vectors and
matrices is the
right thing to do... I was just trying to define vector addition in
terms of a matrix operation
for neatness.
Keean.
More information about the Haskell-Cafe
mailing list