spielwiese
Last change
on this file since bf8015 was
891438c,
checked in by Gerhard Pfister <pfister@…>, 23 years ago
|
*GP: initial release
git-svn-id: file:///usr/local/Singular/svn/trunk@5579 2c84dea3-7e68-4137-9b89-c4e89433aadc
|
-
Property mode set to
100644
|
File size:
865 bytes
|
Line | |
---|
1 | LIB "tst.lib"; |
---|
2 | tst_init(); |
---|
3 | |
---|
4 | LIB"matrix.lib"; |
---|
5 | proc tensorMaps(matrix M, matrix N) |
---|
6 | { |
---|
7 | int r=ncols(M); |
---|
8 | int s=nrows(M); |
---|
9 | int p=ncols(N); |
---|
10 | int q=nrows(N); |
---|
11 | int a,b,c,d; |
---|
12 | matrix R[s*q][r*p]; |
---|
13 | for(b=1;b<=p;b++) |
---|
14 | { |
---|
15 | for(d=1;d<=q;d++) |
---|
16 | { |
---|
17 | for(a=1;a<=r;a++) |
---|
18 | { |
---|
19 | for(c=1;c<=s;c++) |
---|
20 | { |
---|
21 | R[(c-1)*q+d,(a-1)*p+b]=M[c,a]*N[d,b]; |
---|
22 | } |
---|
23 | } |
---|
24 | } |
---|
25 | } |
---|
26 | return(R); |
---|
27 | } |
---|
28 | |
---|
29 | proc tensorMod(matrix Phi, matrix Psi) |
---|
30 | { |
---|
31 | int s=nrows(Phi); |
---|
32 | int q=nrows(Psi); |
---|
33 | matrix A=tensorMaps(unitmat(s),Psi); //Is tensor Psi |
---|
34 | matrix B=tensorMaps(Phi,unitmat(q)); //Phi tensor Iq |
---|
35 | matrix R=concat(A,B); //sum of A and B |
---|
36 | return(R); |
---|
37 | } |
---|
38 | |
---|
39 | ring A=0,(x,y,z),dp; |
---|
40 | matrix M[3][3]=1,2,3,4,5,6,7,8,9; |
---|
41 | matrix N[2][2]=x,y,0,z; |
---|
42 | print(M); |
---|
43 | |
---|
44 | print(N); |
---|
45 | |
---|
46 | print(tensorMod(M,N)); |
---|
47 | |
---|
48 | |
---|
49 | tst_status(1);$ |
---|
Note: See
TracBrowser
for help on using the repository browser.