Items tagged with matrices matrices Tagged Items Feed

I want to analyze the runtimes on certain Linear Algebra functions in Maple, so I need a (large) set of matrices to input into these functions.

I have written the below code, which does succesfully generate a file of matrices:

The resulting file looks like:

However, I am unable to read the matrices from this file back into Maple. When using the code below, I get an error.


I think the error is that %a in fscanf scans up to the next whitespace, so the spacing in Matrix(3, 3, [[9,1,-4],[-5,6,-10],[-10,-4,-4]]) is throwing fscanf off. Do you guys know of any way I can fix this?

 

Or, is there a better way for me to generate these matrices so that they can be easily read into Maple? I've considered using ImportMatrix/ExportMatrix, but I believe that they only work for a single matrix, not the numerous ones that I would need. 

I have worksheet that generates very large matrices and it seems to save all results, so it requires large amount of RAM to load and storage to save it.  

There used to be a pop-up prompt not to save the results of the worksheet - to save space, but that no longer occurs.  Can someone help me to switch on that prompt not to save results or otherwise prevent saving results, when I open the spreadsheet.  It maybe that I agreed not to be prompted again, but now I am regretting it!!

MRB 

I have a system of equations e.g.

A^2+B*A+C=0

where A,B,C are Matrices and I want to solve for A.

Sure I can write every equations in brakets [..=0], but isn'T it possible to just use the matrix notation?

CameraProfiler.mw

D700_Profile.xlsx

This Application uses the xrite color checker to obtain Forward and Color Matrices as defined by Adobe.

It compares the camera gamut based on the above matrices to the 1931 Standard Observer using LEDs.

 

 

 

assume a,b,c,d,B2,B3 are matrices and y is unknown

eq2 := a*b+c*d+a;
eq3 := a*c+c*d+c;
eq4 := a*b+c*a+b*c;
eq5 := a*b+a*d+b*c;
solve([eq2=B2,eq3=B3,eq4=B2,eq5=y],[a,b,c,d]);

which function can solve this kind of system of matrices?

how to solve a,b,c,d in terms of y?

a1 := Matrix(3, [1, 2, 3, 7, 8, 9, 13, 14, 15]);
a2 := Matrix(3, 2, [5, 6, 11, 12, 17, 18]);
a3 := Matrix(2, [19, 20, 25, 26]);
a2 := Matrix(3, 2, [5, 6, 11, 12, 17, 18]);



i want to combine above matrices in big matrix like

A := Matrix(2, 2, [a1, a2, a3, a4]);

best regards

 

Here is my code

restart;
with(LinearAlgebra):
P := unapply(Matrix(4, 4, {(1, 1) = p[w], (1, 2) = p[x], (1, 3) = p[y], (1, 4) = p[z], (2, 1) = -p[x], (2, 2) = p[w], (2, 3) = -p[z], (2, 4) = p[y], (3, 1) = -p[y], (3, 2) = p[z], (3, 3) = p[w], (3, 4) = -p[x], (4, 1) = -p[z], (4, 2) = -p[y], (4, 3) = p[x], (4, 4) = p[w]}),(p[w],p[x],p[y],p[z]));
evalm(P(x,y,z,w));

(y1, y2, y3, y4) -> rtable(1 .. 4, 1 .. 4, {(1, 1) = y1,

(1, 2) = y2, (1, 3) = y3, (1, 4) = y4, (2, 1) = -y2,

(2, 2) = y1, (2, 3) = -y4, (2, 4) = y3, (3, 1) = -y3,

(3, 2) = y4, (3, 3) = y1, (3, 4) = -y2, (4, 1) = -y4,

(4, 2) = -y3, (4, 3) = y2, (4, 4) = y1}, datatype = anything,

subtype = Matrix, storage = rectangular, order = Fortran_order)

 


S:=Matrix(3,5):
for j from 1 to 3 do;
for k from 1 to 5 do;
S[j,k]:=P(seq(RandomTools[Generate](integer(range = 0 .. 4)),i=1..4));;
end do:
end do:
S;
W:=Matrix(3,5):
for j from 1 to 3 do;
for k from 1 to 5 do;
W[j,k]:=Transpose(S[j,k]);;
end do:
end do:
W;

M:=Matrix(3,3,shape=symmetric):
for j from 1 to 3 do;
for k from 1 to j do;
M[j,k]:=P(x[j,k],y[j,k],z[j,k],w[j,k]);
end do:
end do:
M;
N:=Matrix(3,3,shape=antisymmetric):
for j from 1 to 3 do;
for k from j+1 to 3 do;
N[j,k]:=P(u[j,k],v[j,k],q[j,k],r[j,k]);
end do:
end do:
N;
H:=M+N;
(Transpose(W)[2].H.Transpose(Transpose(S)[2]));

I would like the output to be a 4x4 matrix.

Dears, When I run calculation in Maple I found an error in matrices. See the file

 

hi

I am trying to construct a series of 10X10 matrices whose main diagonal contains exactly k ones and other entries zero.

 

plz suggest thanks

Hi all,

I am considering a scenario in which I have, for example, four matrices, A, B, C, and D, which form a basis for all of the (numerical) calculations I am doing.  (For example, A + B = i*C, etc.)  Right now, if I add A and B, I get a matrix back whose elements are i*C, but I cannot get Maple to express it as i*C.  As a simple example, let:

A = (1 0 // 0 1 )

B = (0 1 // -1 0)

C = (i i // -i i)

Then A + B returns (1 1 // -1 1); I'd like for Maple to "intelligently" give iC.  So...how can I get Maple to expand a given matrix (A+B) in terms of a particular basis (here, simply C)?

Thank you.

 

Consider the following code, which just generates two "identical" matrices, differing only in their requested storage type, and then does some simple manipulations.

restart;
#
# Define matrix using sparse storage
#
   testM:= Matrix( 40,40,
                           (i,j)->`if`(j>=i,1,0),fill=0,
                           storage=sparse
                        ):
#
# Define identical(?) matrix with rectangular storage
#
   nm:= Matrix( 40,40,
                        testM,
                        storage=rectangular
                     ):
#
# Define procedure to return some matrix properties
#
   matData:= proc( myMat::Matrix)
                            return op(3, myMat)[2], # check storage type
                                      myMat[5, 1..-1], # get 5-th row
                                      add(myMat[5, 1..-1]); # add elements in 5-th row
                    end proc:
#
# Get properies of the two matrices - should be identical
# but check result of adding elements in the 5-th row
#
    matData(testM);
    matData(nm);

The matData procedure ought to produce the same results for the two matrices, with the exception of the storrage type. But the 'add()' command does not. The 'myMat[5, 1..-1]' command produces the same vector, the 5-th row - but stick an add() wrapper around it and all hell breaks loose.

Is this a bug or am I missing something?

Suggestions such as avoiding sparse data storage are not really acceptable: the above is a much simplified version of my original problem where I was using graph theory to play with a "cost function" and (with G a graph) the command,

WeightMatrix(MinimalSpanningTree(G))

returned a sparse-storage matrix - and I didn't notice. There appears to be no option on the WeightMatrix() command to control the storage tyoe of the returned matrix. Result was that all subsequent code based on slicing/dicing/and particularly 'add()ing' sub-blocks of this weight matrix fell apart

Don't get me wrong: I can sort of accept that the weight matrix of minimal spanning tree would (hopefully) be mainly zeros so sparse-storage might be a good default option but I don't see why the results of a command such as

add(myMat[5, 1..-1])

should vary depending on the internal storage used for the matrix, particularly when I have no control over the storage type being adopted

 

Maple 18.02 on windows. A 4 by 4 matrix, does not display on the screen in nice formating when it has too many elements to fit current screen. But I'd like it to be displayed in 2D just like all the other 4 by 4 matrices and then use the horizontal scroll bar if needed to see the full matrix. Is this possible?

------------------------------------

restart;
z:=theta__1:
T01:=Matrix([
[cos(z),   0,   sin(z),   L*cos(z)],
[-sin(z),  0,  -cos(z),   L*sin(z)],
[0,         1,  0,          0],
[0,         0,  0,          1]]):

z:=theta__2:
T12:=Matrix([
[cos(z),    0,   -sin(z),   L*cos(z)],
[sin(z),    0,    cos(z),   L*sin(z)],
[0,         1,  0,          0],
[0,         0,  0,          1]]):

z:=theta__3:
T23:=Matrix([
[cos(z),    0,   -sin(z),   L*cos(z)],
[sin(z),    0,    cos(z),   L*sin(z)],
[0,         -1,  0,          0],
[0,         0,  0,          1]]):

T02   := T01.T12;
T03   := T02.T23;
LinearAlgebra[Dimension](T03);
------------------------------------------------

T02 above displays in 2D fine. But T03 does not on standard 100% zoom on my monitor. Screen shot:

When I changed the zoom to 50%, now it did format ok on the screen:

May be I need a way to activate the horizontal screel bar? I really do not want to keep changing zoom each time I want to see a larger matrix. All the matrices are 4 by 4, but some of them can end up with many terms in each entry.

Hi,

for my simulation I have to calculate several gradients and jacobian matrices. The equations are quite complex and with my current setup hard to read.

 

Here is some exampel code:

restart;
with(VectorCalculus);
SetCoordinates(cartesian[x, y, z]);
alias(u = u(t, x, y, z), v = v(t, x, y, z), w = w(t, x, y, z)); alias(eta = eta(t, x, y, z));
U := VectorField(`<,>`(u, v, w));
Divergence(U);
Jacobian(U);
Diff(U, t);

The Divergence operator gives me a very compact result:

But Jaobian and Diff look like:

 

To achive a better readability I want to do two things (if possible):

1) hide the independet variables (t,x,y,z) in the result of Jacobian, Diff

2) display the result of Diff in a row vector (3x1) instead

 

Is this possible?

Thanks in advance for your help

 

 

I am trying to learn the <> notation to enter matrices and vectors. But I find this page very confusing

http://www.maplesoft.com/support/help/maple/view.aspx?path=examples%2FLA_Syntax_Shortcuts

it says:

but we see clearly the vertical bars are used to separate columns.

Isn't a column the thing that goes from the top to bottom and not from left to right in Maple LinearAlgebra?

 

Hi all

Can anybody suggest an algorithm allowing to detect, that two matrices of the same size can be obtained each from other by permutations of rows and columns? Maybe, such an algorithm there exists in LinearAlgebra package?

1 2 3 4 Page 1 of 4