Items tagged with matrix

I have a Maple code which generates a matrix, saves it to a .txt file and this is then read in to a C++ program. I have hit a snag with these matrices, in that they are generating absolutely enourmous .txt files. I need to get to a 5000*5000 matrix yet a 200*200 is generating a 100MB file.

The matrix elements contain a lot of algebraic terms which I would like to keep general as these are defined in the C++ code. They also contain hypergeometric functions which in the example below I have left unsimplified (although they are simplified before reaching C++). I have tried various operations/combinations to simplify, but the file sizes still come out very large.

From previous experience expanding the expressions and then simplifying allows Maple to "do more" with it, but it does not seem to work in this instance. I have tried map(options,expr), simplify(expr,options), combine(expr,options), convert (expr,options) etc... The script attached only contains a small example 10*10 matrix on its own without the code which generates it due to the size of the code. What is the best way to simplify these matrices to generate the smallest .txt file?

Large_Matrix.mw

Any help is appreciated.


-Yeti
 

Dears,

I have a question and I hope someone will be able to answer it.

I would like to create a matrix of functions depending on the number of the line or the arrow. I think the best is to show with a very basic example:

I have the following program

n:=4:

R:=Matrix(1,n):

for i from 1 to n do: R(1,i):=x->i*x:end do:

So, I have a matrix, one row, n columns. At the ith column, I want to have the function f(x)=i*x.

Unfortutanely, with my program, I obtain for example for the first column the function f(x)=11*x. At the second column, I get the same result. It seems that I can define matrices of functions but it is impossible in the definition of the function to use the number of the column. Do you have any idea about how to write a program?

Any help would be very appreciated. 

 

 

Hello,

To check my arguments in a procedure I need something like

myproc := proc(M :: Matrix(square, rational)

                       , N :: Matrix(shape=triangular[lower, unit], datatype = rational
                       , O :: Matrix(shape = square, dimension = 5

               )

end proc;

How does that work in Maple? What is the correct Syntax? I tried many different things that doesn't fit.

I am trying to use a do loop with if/else statements to create a 5x5 unit matrix. I made an empty array. Converted it to a matrix. Then made a do loop where I was trying to get the matrix elements where i=j to be 1 and all else to be 0. It didn't spit out a matrix.

Any advice? I assume I must have missed a small detail in syntax.


 

with(LinearAlgebra):

````

U := array(1 .. 5, 1 .. 5);

array( 1 .. 5, 1 .. 5, [ ] )

(1)

NULL

for i to 5 do for j to 5 do if i = j then U[i, j] := 1 else U[i, j] := 0 end if end do end do

U;

U

(2)

``


 

Download fail_unit_matrix_loop.mw

By the way, I am open to completely different methods, also! I was just trying to use loops to do it rather than inbuilt commands.

Pay attention to the Next Question

 

I have to find which column of a matrix contains repeated elements, i have done it in this but i'm afraid that the nested loops don't run correctly:

for j by 1 to 10 do 
for i by 1 to 30 do 
	h:=Dati[i,j];
	for x by 1 to 30 do
		
		if Dati[x,j] = h then
			if x <> i then
				return j;
				end if;
				end if;
				end do;
				 end do;
				  end do;

 

How can i convert each column of a matrix(30X10) in a list?

Hi everybody

In the attached file, when I run the code an error appears while calculating "omegaL1" parameter. The dimensions of the matrices are correct but the source of error is unknown to me. Can anyone help me?

Thanks in advance

R2_Link_2D.mw 

I'm trying to use subs to substitute an unknown variable with a number in a Matrix

My Matrix is called values and I have the following

change := f2:

subs(change = 5, values):

This does nothing but when I have the following, it works as expected (All f2 in the Matrix values are replaced with 5)

subs(f2,values):

I'm wondering if its trying to find and replace 'change'. If this is the case how can I get it to use whats assigned to the variable. (I've tried eval(change) but that doesn't work either)

Many thanks

does anybody know how to copy a rtable structure in a worksheet and paste it on the other worksheet?

I copy it by right click and paste on the other one but no data transfered.

Good day, I need to 2D plot from points which I get by solving numerically 17-degree equations. Firstly I take an only first solution of the equation as below, and I have a Matrix with 3 column which represents X, Y, and VALUE respectively. On the left side should be the first column ( X ), and right axis Y (2. column). As seen from Matrix X and Y getting the value between 0 and 10. Is there any option that I can plot my data in 2D?  Thanks in advance.


points := seq(seq(seq(Fun[n, i, j], n = 0 .. step), i = 0 .. step), j = 1);
Mat := Matrix((step+1)^2, 3, [points]);
         .                             X                  Y                 VALUE
           
with(plots);
pointplot3d(Mat, style = point, color = black);
 
 

Since GramSchmidt does not take Matrix as an input (I wish it did), I would like to know how to normalize a matrix rows. For example if input matrix is:

M = [  1    2]
       [  3    4]

How do I convert it into

Mn = [ 1/sqrt(5)    2/sqrt(5) ]
         [ 3/5            4/5          ]

Each row of matrix Mn has length of 1.

Thank you.

 

I am using matrices to input data in order to plot it on a surface plot. Is it then possible to export an animation of this graph rotating around an axis?

My matrix is 40 x 3 Matrix

 

Thanks :)

Assume you have a matrix A and somewhere you want to make a copy of it like B and working with them independently. Let's say you have a loop and after doing a proc on B again you have to make it equal to A. So changes on B shouldn't effect on A. What is the common way of taking such copies of A in Maple?

The following methods don't work.
 

A:=Matrix(3);
B:=A;
B(1,1):=1;
A;
A:=Matrix(3);
B:=subs(B=A,B);
B(1,1):=1;
A;

What I came up with is the following but it will look weird if one really needs to write something meaningless like *2/2.

A:=Matrix(3);
B := (1/2)*subs(B = 2*A, B);
B(1,1):=1;
A;

 

1 2 3 4 5 6 7 Last Page 1 of 46