ahmet alper parker | 17 May 15:52
Picon

simple question

Dear all,
I have a very simple question. If you can answer, I really appreciate. How can I build a matrix with all its elements zero with a simple command?
In example I want to build a matrix like

A=matrix(
 [0,0,0],
 [0,0,0],
 [0,0,0]
);

but it is very hard to make it if you define all the elements and if you have say a 100*100 matrix.
There should be a simple command but I cannot find it in the manual. Also its elements are not forced to be zero. I want to make A a matrix with 100*100 elements in example. Then I will define myself its elements with a for next like loop...

Best Regards
Ahmet Alper Parker

_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
Andrej Vodopivec | 17 May 16:01
Picon

Re: simple question

2008/5/17 ahmet alper parker <aaparker <at> gmail.com>:
> Dear all,
> I have a very simple question. If you can answer, I really appreciate. How
> can I build a matrix with all its elements zero with a simple command?
> In example I want to build a matrix like
>
> A=matrix(
>  [0,0,0],
>  [0,0,0],
>  [0,0,0]
> );
>
> but it is very hard to make it if you define all the elements and if you
> have say a 100*100 matrix.
> There should be a simple command but I cannot find it in the manual. Also
> its elements are not forced to be zero. I want to make A a matrix with
> 100*100 elements in example. Then I will define myself its elements with a
> for next like loop...

You are looking for zeromatrix:

(%i1) ?! zeromatrix;
 -- Function: zeromatrix (<m>, <n>)
     Returns an <m> by <n> matrix, all elements of which are zero.
  There are also some inexact matches for `zeromatrix'.
  Try `?? zeromatrix' to see them.
(%o1) true
(%i2) zeromatrix(4,4);
(%o2) matrix([0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0])

--

-- 
Andrej
Alasdair McAndrew | 17 May 16:07
Picon

Re: simple question

More generally, genmatrix will construct a matrix using any function of the indices you like, so that

genmatrix(lambda([i,j],0),100,100);

will produce a 100x100 zero matrix.

On Sat, May 17, 2008 at 11:52 PM, ahmet alper parker <aaparker <at> gmail.com> wrote:
Dear all,
I have a very simple question. If you can answer, I really appreciate. How can I build a matrix with all its elements zero with a simple command?
In example I want to build a matrix like

A=matrix(
 [0,0,0],
 [0,0,0],
 [0,0,0]
);

but it is very hard to make it if you define all the elements and if you have say a 100*100 matrix.
There should be a simple command but I cannot find it in the manual. Also its elements are not forced to be zero. I want to make A a matrix with 100*100 elements in example. Then I will define myself its elements with a for next like loop...

Best Regards
Ahmet Alper Parker

_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima


_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima

Gmane