Items tagged with matrices

Feed

I have written a Maple code which extracts terms in a matrix into two new matrices dependent on certain markers. I am running into problems with this particular code as it requires enormous amounts of RAM when going to large matrix sizes (32GB+); and will take 4-5 days to complete for larger matrix sizes, or simply crashes.

Each matrix element is an algebraic expression containing A and B and the markers hh and ss. The example in the attached Maple file (3 x 3 matrix) is a minimal working example and the actual expressions are much longer and the matrices much larger (5000 x 5000 or larger). I utilise the symmetry of the matrix to ease the process, and use the tril command of MTM to extract only the lower triangular matrix; as this is all that is needed for the next stage (I have yet to test how efficient this command is, but use it for now).

The two markers hh and ss are targeted and if found in an expression that term will be extracted accordingly. The matrix elements are expanded and a procedure run over the matrix and will extract terms with hh into one matrix and terms with ss into another matrix. I think the map(expand,...) part is what causes the memory issue; but I believe this needs to be done to correctly extract terms.

Any help or tips are greatly appreciated on how to increase efficiency and improve this method.
 

Sub_matrix_extraction.mw

-Yeti

 

 

Hello guys!

Could you tell me what are the state-of-the-art algorithms to compute Hermite and Smith normal forms (well or just Hermite since the later can be computed by applying Hermite twice)? I am interested in these algorihtms which outputs also the respective unimodular matrices.

 

Hello maple users. 

I am learning to use this incredible software, but I am not getting to obtain all binary 4x4 matrices of rank 3 and 4?

Anyone knows how to do that ?

Thanks
My best regards!

Gustavo

Hello,

I am trying to write a procedure to see, which (di)-graphs are isomorphic (here represented by there 3*3 adjecency-matrices). When I try the procedure for all 3*3-matrices with entries in {0,1} (there are 512 of them), I get the following error:
"Error, (in GraphTheory:-IsIsomorphic) invalid subscript selector"

Can you possibly say, what I am doing wrong? My code is the following:

getIso3 := proc(liste)
  local i,k,M1,c,d:
  c := 0:
  M1 := [[liste[1]]]:
  for i from 2 to numelems(liste) do
    for k from 1 to numelems(M1) do
        if IsIsomorphic(Digraph([a,b,c], liste[i]),Digraph([a,b,c],M1[k][1])) then
          M1[k] := [op(M1[k]), liste[i]]:
          c := 1:
        end if:
    end do:
    if c=0 then
      M1 := [op(M1), [liste[i]]]:
    else
      c := 0:
    end if:   end do: 
  return(M1):
end proc:

 

My input is a list (JJ) of 512 3*3 matrices constructed the following way :

all9Perm := proc(list)
  local P,i,m,n,A:
  P := list:
  for i from 0 to 9 do
    m:= i:  n:= 9-i:
    A := combinat:-permute([1$n, 0$m]):
    P := [op(P), op(1..numelems(A),A)]:
  od:
  return(P):
end proc:
K := []:
L := all9Perm(K):
listoflistsToListofmatrices := proc(liste)
  local M,i:
  M := []:
  for i from 1 to numelems(liste) do
      M := [op(M), Matrix([
          [ liste[i][1] , liste[i][2] , liste[i][3] ],
          [ liste[i][4] , liste[i][5] , liste[i][6] ],
          [ liste[i][7] , liste[i][8] , liste[i][9] ]])
          ]:
  end do:
  return(M):
end proc:
JJ := listoflistsToListofmatrices(L):

 

When I run this procedure on some of the 512 matrices it does work, but it crashes somewhere around matrix 350. I have try so split the list of the 512 matrices, and I am able to run the procedure on these splits, but this is very inconvenient :-)

I hope you can help me. Also if this can be done in an easier way - I am new to programming and recieve help with a smile.

Yours, Tomas.

Hi,

I have two same dimentional matrix(1000*1000), one is full of variables and the other is full of numbers. What is the simplest way to assign the values of second matrix to first one variables?

for example:

A := Matrix([[x, y], [z, t]]);

B := Matrix([[1, 2], [3, 4]]);

How assign B's values to A's variables, in such a way that after assigning ,when call x, the 1 appears in output.

 


 

``

restart

Error, invalid input: with expects its 1st argument, pname, to be of type {`module`, package}, but received shareman

 

A := Matrix([[x, y], [z, t]])

A := Matrix(2, 2, {(1, 1) = x, (1, 2) = y, (2, 1) = z, (2, 2) = t})

(1)

B := Matrix([[1, 2], [3, 4]])

B := Matrix(2, 2, {(1, 1) = 1, (1, 2) = 2, (2, 1) = 3, (2, 2) = 4})

(2)

NULL

x

x

(3)

``

 

 

 

``


 

Download assgnSoal.mw

I am solving a matrix eigenvalue problem, and have found a way to make the matrices very sparse by a set of conditions x=x', y=y' and z=z'. If these are satisfied then the matrix element will be >0. If any one of them is not satisfied, then the matrix element becomes zero; hence a sparse matrix is formed. Mathematically in Maple this can be represented as such:

ME*KroneckerDelta[x,xp]*KroneckerDelta[y,yp]*KroneckerDelta[z,zp];

Where ME represents the matrix element and xp, yp, zp represent the prime notation . I apply this form within a C++ routine which I am extracting the matrices from into Maple where I am looking to modify them to experiment with an extension of the program.

The matrices I read into Maple have had the Kronecker delta functions applied, however Is there a simple way to reverse the effect of the Kronecker delta functions with the Matrix in Maple and return the Matrix equivalent to just ME without the product of kronecker delta functions?

-Yeti

I have two symmetric real matrices as below (Mt,Kk).

I multilpy them in Mt.Kk.Mt.

But the result is not symmetric.!!!!why????

 

``

restart; with(LinearAlgebra)

Error, invalid input: with expects its 1st argument, pname, to be of type {`module`, package}, but received shareman

 

Mt := ImportMatrix("C:/Mt.mpl"); -1; Norm(Mt-LinearAlgebra:-HermitianTranspose(Mt), 2)

0.

(1)

Kk := ImportMatrix("C:/Kk.mpl"); -1; Norm(Kk-LinearAlgebra:-HermitianTranspose(Kk), 2)

0.

(2)

Aa := Typesetting:-delayDotProduct(Typesetting:-delayDotProduct(Mt, Kk), Mt); -1; Norm(Aa-LinearAlgebra:-HermitianTranspose(Aa))

4608.00000953674316

(3)

Aa

RTABLE(18446744074182082558, complex[8], Matrix, rectangular, Fortran_order, [], 2, 1 .. 45, 1 .. 45)

(4)

``

``

``

``

``

``

``

``

``

``

``

``

``

Download question.mw

I couldnt upload Kk.mlp and Mt.mlp so changed their extensions to mw. for using please change them to .mlp

Download Kk.mw

Download Mt.mw

 

fn1 and gn1 are the 2x2 matrices. For example
 

fn1:=Matrix(2,2,[seq(f[i],i=1..4)])
gn1:=Matrix(2,2,[seq(g[i],i=1..4)])


eq1:=evalm(Matrix(2,2, [1, 1, 0, 3])&*fn1+gn1)=Matrix(2,2,[0]);

eq2:=evalm(fn1+gn1)=Matrix(2,2, [0]);

how can we find fn1 and gn1 matrices?

For some strange reason my matrices are shown in a very bizarre format (see imgur link). All I want is to simply see the 6x6 matrix with the numerical values - any help would be greatly appreciated. http://imgur.com/a/qaQmb

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?

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.

1 2 3 4 Page 1 of 4