Re: Matrix Algebra
Arthur Adamson writes:
> global type vector(integer len)
> --type vector(x) creates and initializez ax x element vector to 0
>
> sequence s
> s = {0.0}
>
> for i = 2 to len by 1 do s = s & {0}
> end for
> return s
> end type
In Euphoria a "type" should return 0 (FALSE) or non-zero (TRUE).
Perhaps you mean "function".
In this code and some similar code that you posted I would rather
see something like:
repeat(0, x) -- standard Euphoria library routine, repeats 0 x times
rather than a "&" or append() loop. repeat() is simpler, executes faster, and
handles the case of length 0 correctly. (Of course by initializing s
to the empty sequence, {}, and running the for-loop from 1 to n,
the loop method above could also handle length-0 correctly).
You can initialize a "2-dimensional" sequence using:
z = repeat(repeat(0,x), y)
and so on for 3-d, 4-d etc.
Other than that, I think a matrix algebra package could be quite useful.
I don't know of anyone who is working on one.
Regards,
Rob Craig
Rapid Deployment Software
|
Not Categorized, Please Help
|
|