Sponsored links: Algebra eBooks
 

Related

copymatrix

Run Example
(%i1)A:matrix([3,4,5],[2,1,0],[3,6,7]);
                                  [ 3  4  5 ]
                                  [         ]
(%o1)                             [ 2  1  0 ]
                                  [         ]
                                  [ 3  6  7 ]
(%i2) A[1];
(%o2)                              [3, 4, 5]
(%i3) row(A,1);
(%o3)                             [ 3  4  5 ]
(%i4) col(A,1);
                                     [ 3 ]
                                     [   ]
(%o4)                                [ 2 ]
                                     [   ]
                                     [ 3 ]
(%i5) A[1,1]:-1;
(%o5)                                 - 1
(%i6) A;
                                 [ - 1  4  5 ]
                                 [           ]
(%o6)                            [  2   1  0 ]
                                 [           ]
                                 [  3   6  7 ]
(%i7) A[2]:[2,2,2];
(%o7)                              [2, 2, 2]
(%i8) A;
                                 [ - 1  4  5 ]
                                 [           ]
(%o8)                            [  2   2  2 ]
                                 [           ]
                                 [  3   6  7 ]
(%i9) transpose(A);
                                 [ - 1  2  3 ]
                                 [           ]
(%o9)                            [  4   2  6 ]
                                 [           ]
                                 [  5   2  7 ]
(%i10)  At:transpose(A);
                                 [ - 1  2  3 ]
                                 [           ]
(%o10)                           [  4   2  6 ]
                                 [           ]
                                 [  5   2  7 ]
(%i11)  A.A;
                                [ 24  34  38 ]
                                [            ]
(%o11)                          [ 8   24  28 ]
                                [            ]
                                [ 30  66  76 ]
(%i12) A*A;
                                 [ 1  16  25 ]
                                 [           ]
(%o12)                           [ 4  4   4  ]
                                 [           ]
                                 [ 9  36  49 ]
(%i13) B:A;
                                 [ - 1  4  5 ]
                                 [           ]
(%o13)                           [  2   2  2 ]
                                 [           ]
                                 [  3   6  7 ]
(%i14) A[1,1]:5;
(%o14)                                 5
(%i15) B;
                                  [ 5  4  5 ]
                                  [         ]
(%o15)                            [ 2  2  2 ]
                                  [         ]
                                  [ 3  6  7 ]
(%i16) B:copymatrix(A);
                                  [ 5  4  5 ]
                                  [         ]
(%o16)                            [ 2  2  2 ]
                                  [         ]
                                  [ 3  6  7 ]
(%i17) A[1,1]:3;
(%o17)                                 3
(%i18) B;
                                  [ 5  4  5 ]
                                  [         ]
(%o18)                            [ 2  2  2 ]
                                  [         ]
                                  [ 3  6  7 ]
(%i19) 
Run Example
S:3;
(%o1)                                  3
(%i2) A:2;
(%o2)                                  2
(%i3) xRef:20;
(%o3)                                 20
(%i4) X3:matrix([15,28,28],[35,19,20]);
                                [ 15  28  28 ]
(%o4)                           [            ]
                                [ 35  19  20 ]
(%i5) wS2:[0.1,0.4,0.5];
(%o5)                           [0.1, 0.4, 0.5]
(%i6) X2:copymatrix(X3)-xRef;
                                [ - 5   8   8 ]
(%o6)                           [             ]
                                [ 15   - 1  0 ]
(%i7) X:matrix([X2[1,1],X2[1,2]],[X2[2,1],X2[2,2]]);
                                 [ - 5   8  ]
(%o7)                            [          ]
                                 [ 15   - 1 ]
(%i8) wS:matrix([wS2[1],wS2[2]+wS2[3]],[wS2[1],wS2[2]]);
                                 [ 0.1  0.9 ]
(%o8)                            [          ]
                                 [ 0.1  0.4 ]
(%i9) Piw_Prop:0.15;
(%o9)                                0.15
(%i10) Piw_Growth:1.6;
(%o10)                                1.6
(%i11) PiwS[a,s]:=Piw_Prop*%e^(Piw_Growth*wS[a,s]);
                                          Piw_Growth wS
                                                       a, s
(%o11)             PiwS     := Piw_Prop %e
                       a, s
(%i12) genmatrix(PiwS,2,2);
                    [ 0.17602663064877  0.63310437254948 ]
(%o12)              [                                    ]
                    [ 0.17602663064877  0.28447213189574 ]
(%i13) v_Exponent:0.7;
(%o13)                                0.7
(%i14) v_Lossav:2.3;
(%o14)                                2.3
(%i15) v(x):= if x>
=0 then x^v_Exponent else (-v_Lossav)*(-x)^v_Exponent;
                               v_Exponent                        v_Exponent
(%o15) v(x) := if x >= 0 then x           else (- v_Lossav) (- x)
(%i16) Phi[1];
(%o16)                               Phi
                                        1
(%i17) Phi[2];
(%o17)                               Phi
                                        2
(%i18) posX3:copymatrix(X3);
                                [ 15  28  28 ]
(%o18)                          [            ]
                                [ 35  19  20 ]
(%i19) posX3[1,1]:xRef+1;
(%o19)                                21
(%i20) Xpos:copymatrix(X);
                                 [ - 5   8  ]
(%o20)                           [          ]
                                 [ 15   - 1 ]
(%i21) Xpos[1,1]:1;
(%o21)                                 1
(%i22) Phipos1:v(Xpos[1,1])+PiwS[1,2]*(v(Xpos[1,2])-v(Xpos[1,1]));
(%o22)                         3.081073489507423
(%i23) /* neuer Präferenzwert (Berechnet für strikt positive Alternative 1)*/R(Delta):=if Delta>
=0 then Delta^2 else -(Delta)^2;
                                                  2             2
(%o23)        R(Delta) := if Delta >= 0 then Delta  else - Delta
(%i24) X2[1,1]:1;
(%o24)                                 1
(%i25) RPhi[a]:=sum(wS2[s]*(v(X2[a,s])+R(v(X2[a,s])-v(X2[3-a,s]))),s,1,3);
(%o25) RPhi  := sum(wS2  (v(X2    ) + R(v(X2    ) - v(X2        ))), s, 1, 3)
           a           s      a, s          a, s        3 - a, s
(%i26) tans1: wS[1,1];
(%o26)                                0.1
(%i27) tans2: wS[1,2];
(%o27)                                0.9
(%i28) tans3: X[1,1];
(%o28)                                - 5
(%i29) tans4: X[1,2];
(%o29)                                 8
(%i30) tans5: wS[2,1];
(%o30)                                0.1
(%i31) tans6: wS[2,2];
(%o31)                                0.4
(%i32) tans7: X[2,1];
(%o32)                                15
(%i33) tans8: X[2,2];
(%o33)                                - 1
(%i34) tans9: PiwS[1,1];
(%o34)                         0.17602663064877
(%i35) tans10: PiwS[1,2];
(%o35)                         0.63310437254948
(%i36) tans11: v(X[1,1]);
(%o36)                        - 7.095889421280109
(%i37) tans12: v(X[1,2]);
(%o37)                         4.287093850145172
(%i38) tans13: PiwS[2,1];
(%o38)                         0.17602663064877
(%i39) tans14: PiwS[2,2];
(%o39)                         0.28447213189574
(%i40) tans15: v(X[2,1]);
(%o40)                         6.656775051475124
(%i41) tans16: v(X[2,2]);
(%o41)                               - 2.3
(%i42) tans17: Phi[1];
(%o42)                               Phi
                                        1
(%i43) tans18: Phi[2];
(%o43)                               Phi
                                        2
(%i44) tans19: if Phi[1]>
Phi[2] then 1 else 2;
(%o44)                   if Phi  > Phi  then 1 else 2
                               1      2
(%i45) tans20: Phipos1;
(%o45)                         3.081073489507423
(%i46) tans21: if Phipos1>
Phi[2] then 1 else 2;
(%o46)             if 3.081073489507423 > Phi  then 1 else 2
                                             2
(%i47) tans22: RPhi[1];
(%o47)                         27.30398306305592
(%i48) tans23: RPhi[2];
(%o48)                        - 23.59992109277776
(%i49) tans24: if RPhi[1]>
RPhi[2] then 1 else 2;
(%o49)                                 1
(%i50) 
Run Example
get_deg_occ(eq,alist):=block(	[atomlistlen,deglist,occlist,i],	atomlistlen: length(alist),	deglist: makelist(0,ii,1,atomlistlen),	occlist: makelist(0,ii,1,atomlistlen),	for i:1 thru atomlistlen do (		deglist[i]: hipow(eq,alist[i]),		if deglist[i]>
0 then (			occlist[i]: 1		)	),	return([deglist,occlist]));
(%o1) get_deg_occ(eq, alist) := block([atomlistlen, deglist, occlist, i], 
atomlistlen : length(alist), deglist : makelist(0, ii, 1, atomlistlen), 
occlist : makelist(0, ii, 1, atomlistlen), 
for i thru atomlistlen do (deglist  : hipow(eq, alist ), 
                                  i                  i
if deglist  > 0 then occlist  : 1), return([deglist, occlist]))
          i                 i
(%i2) remove_col_row(dmatrix,omatrix,aelist,atomlistlen,eqlistlen,sumvalue):=block(	[degmatrix,occmatrix,llist,llistlen,latomlistlen,leqlistlen,ret,pos,i],	degmatrix: copymatrix(dmatrix),	occmatrix: copymatrix(omatrix),	llist: copylist(aelist),	latomlistlen: atomlistlen,	leqlistlen: eqlistlen,	ret: false,	while ret=false do (		pos: 0,		for i:1 thru latomlistlen do (			if sum(occmatrix[ii,i],ii,1,leqlistlen)=sumvalue then (				if sumvalue=0 then (					print("Column ",i," has sum=0 (atom=",llist[i],") and must be removed")				)				else (					/* sumvalue=1 */					print("Column ",i," has sum=1 and must be removed")				),				pos: i,				return(pos)			)		),		if pos>
0 then (			if sumvalue=0 then (				/* remove column pos from degmatrix and occmatrix, remove pos-th atom from atomlist */				degmatrix: submatrix(degmatrix,pos),				occmatrix: submatrix(occmatrix,pos),				llist: delete(llist[pos],llist),				latomlistlen: length(llist)			)			else (				/* sumvalue=1 */				/* remove row pos from degmatrix and occmatrix, remove pos-th equation from eqlist */				degmatrix: submatrix(pos,degmatrix),				occmatrix: submatrix(pos,occmatrix),				llist: delete(llist[pos],llist),				leqlistlen: length(llist)			)		)		else (			ret: true		),		if sumvalue=0 and latomlistlen=0 then (			error("no atoms remaining")		)		else if sumvalue=1 and leqlistlen=0 then (			error("no equations remaining")		)	),	return([degmatrix,occmatrix,llist]));
(%o2) remove_col_row(dmatrix, omatrix, aelist, atomlistlen, eqlistlen, 
sumvalue) := block([degmatrix, occmatrix, llist, llistlen, latomlistlen, 
leqlistlen, ret, pos, i], degmatrix : copymatrix(dmatrix), 
occmatrix : copymatrix(omatrix), llist : copylist(aelist), 
latomlistlen : atomlistlen, leqlistlen : eqlistlen, ret : false, 
while ret = false do (pos : 0, for i thru latomlistlen 
do if sum(occmatrix     , ii, 1, leqlistlen) = sumvalue
                   ii, i
 then (if sumvalue = 0 then print("Column ", i, " has sum=0 (atom=", llist , 
                                                                          i
") and must be removed") else print("Column ", i, 
" has sum=1 and must be removed"), pos : i, return(pos)), 
if pos > 0 then (if sumvalue = 0 then (degmatrix : submatrix(degmatrix, pos), 
occmatrix : submatrix(occmatrix, pos), llist : delete(llist   , llist), 
                                                           pos
latomlistlen : length(llist)) else (degmatrix : submatrix(pos, degmatrix), 
occmatrix : submatrix(pos, occmatrix), llist : delete(llist   , llist), 
                                                           pos
leqlistlen : length(llist))) else ret : true, 
if (sumvalue = 0) and (latomlistlen = 0) then error("no atoms remaining")
 else (if (sumvalue = 1) and (leqlistlen = 0)
 then error("no equations remaining"))), return([degmatrix, occmatrix, llist]))
(%i3) pdesys2pde(alist,atlist,elist,etlist):=block(	[atomlist,atomtlist,eqlist,eqtlist,atomlistlen,atomtlistlen,eqlistlen,eqtlistlen,degmatrix,occmatrix,deglist,occlist,i,j,deg,ret,pos,neqlist,neqlistlen,nneqlist],	eqlist: copylist(elist),	eqtlist: copy(etlist),	atomlist: copylist(alist),	atomtlist: copylist(atlist),	eqlistlen: length(eqlist),	eqtlistlen: length(eqtlist),	atomlistlen: length(atomlist),	atomtlistlen: length(atomtlist),	/* for each equation, get the highest degree for each t-atom */	degmatrix: matrix(),	/* for each atom, get the number of occurrences in the equation set */	occmatrix: matrix(),	for i:1 thru eqtlistlen do (		[deglist,occlist]: get_deg_occ(eqtlist[i],atomtlist),		degmatrix: addrow(degmatrix,deglist),		occmatrix: addrow(occmatrix,occlist)	),print("Start: ",degmatrix),print("Start: ",occmatrix),return(0),	/* remove (recursively) all rows, whose sum is 1, that is, all equation containing atom occuring only once */	[degmatrix,occmatrix,eqlist]: remove_col_row(degmatrix,occmatrix,eqlist,atomlistlen,eqlistlen,1),	eqlistlen: length(eqlist),/*	ret: false,	while ret=false do (		pos: 0,		for i:1 thru atomlistlen do (			if sum(occmatrix[ii,i],ii,1,eqlistlen)=1 then (				print("Column ",i," has sum=1 and must be removed"),				pos: i,				return(pos)			)		),		if pos>
0 then (			-- remove row pos from degmatrix and occmatrix, remove pos-th equation from eqlist --			degmatrix: submatrix(pos,degmatrix),			occmatrix: submatrix(pos,occmatrix),			eqlist: delete(eqlist[pos],eqlist),			eqlistlen: length(eqlist)		)		else (			ret: true		),		if eqlistlen=0 then (			error("no equations remaining")		)	),*/	/* now remove (recursively) all columns, whose sum is 0: these variables are not used */	[degmatrix,occmatrix,atomlist]: remove_col_row(degmatrix,occmatrix,atomlist,atomlistlen,eqlistlen,0),	atomlistlen: length(atomlist),/*	ret: false,	while ret=false do (		pos: 0,		for i:1 thru atomlistlen do (			if sum(occmatrix[ii,i],ii,1,eqlistlen)=0 then (				print("Column ",i," has sum=0 (atom=",atomlist[i],") and must be removed"),				pos: i,				return(pos)			)		),		if pos>
0 then (			/* remove column pos from degmatrix and occmatrix, remove pos-th atom from atomlist */			degmatrix: submatrix(degmatrix,pos),			occmatrix: submatrix(occmatrix,pos),			atomlist: delete(atomlist[pos],atomlist),			atomlistlen: length(atomlist)		)		else (			ret: true		),		if atomlistlen=0 then (			error("no atoms remaining")		)	),*//*	for i:atomlistlen thru 1 step -1 do (		if sum(occmatrix[ii,i],ii,1,eqlistlen)=0 then (			-- remove column i from degmatrix and occmatrix, remove i-th atom from atomlist --			degmatrix: submatrix(degmatrix,i),			occmatrix: submatrix(occmatrix,i),			print("Column ",i," has sum=0 (atom=",atomlist[i],") and must be removed"),			atomlist: delete(atomlist[pos],atomlist)		)	),	atomlistlen: length(atomlist),*/print("End: ",atomlist),print("End: ",eqlist),print("End: ",degmatrix),print("End: ",occmatrix),return(0),	/* now, each atom exists in at least 2 equations */	/* reduce the set of equations, by eliminating the atoms starting by the highest derivative (x+t) */print("***"),	/* WWWHHH */	pos: atomlistlen,	neqlist: [],	for i:eqlistlen thru 1 step -1 do (		if occmatrix[i,pos]=1 then (print(i),			neqlist: append(neqlist,[eqlist[i]]),			/* remove row i from degmatrix and occmatrix */			degmatrix: submatrix(degmatrix,i),			occmatrix: submatrix(occmatrix,i)		)	),	nneqlist: [],	/* choose the data based on the degree! */	/* this is the basic variation: first equation is fixed */	for i:2 thru neqlistlen do (		nneqlist: append(nneqlist,[resultant(neqlist[1],neqlist[i],atomlist[pos])])	),	neqlist: copylist(nneqlist),	neqlistlen: length(neqlist),	atomlist: delete(atomlist[pos],atomlist),	atomlistlen: length(atomlist),	/* add row to degmatrix and occmatrix */	for i:1 thru neqlistlen do (		[deglist,occlist]: get_deg_occ(neqlist[i],atomlist),		degmatrix: addrow(degmatrix,deglist),		occmatrix: addrow(occmatrix,occlist)	),	/* now remove columns with sum=0 */	/* WWWHHH */	return(0));
(%o3) pdesys2pde(alist, atlist, elist, etlist) := 
block([atomlist, atomtlist, eqlist, eqtlist, atomlistlen, atomtlistlen, 
eqlistlen, eqtlistlen, degmatrix, occmatrix, deglist, occlist, i, j, deg, ret, 
pos, neqlist, neqlistlen, nneqlist], eqlist : copylist(elist), 
eqtlist : copy(etlist), atomlist : copylist(alist), 
atomtlist : copylist(atlist), eqlistlen : length(eqlist), 
eqtlistlen : length(eqtlist), atomlistlen : length(atomlist), 
atomtlistlen : length(atomtlist), degmatrix : matrix(), occmatrix : matrix(), 
for i thru eqtlistlen do ([deglist, occlist] : 
get_deg_occ(eqtlist , atomtlist), degmatrix : addrow(degmatrix, deglist), 
                   i
occmatrix : addrow(occmatrix, occlist)), print("Start: ", degmatrix), 
print("Start: ", occmatrix), return(0), 
[degmatrix, occmatrix, eqlist] : remove_col_row(degmatrix, occmatrix, eqlist, 
atomlistlen, eqlistlen, 1), eqlistlen : length(eqlist), 
[degmatrix, occmatrix, atomlist] : remove_col_row(degmatrix, occmatrix, 
atomlist, atomlistlen, eqlistlen, 0), atomlistlen : length(atomlist), 
print("End: ", atomlist), print("End: ", eqlist), print("End: ", degmatrix), 
print("End: ", occmatrix), return(0), print("***"), pos : atomlistlen, 
neqlist : [], for i from eqlistlen step - 1 thru 1 
do if occmatrix       = 1 then (print(i), 
               i, pos
neqlist : append(neqlist, [eqlist ]), degmatrix : submatrix(degmatrix, i), 
                                 i
occmatrix : submatrix(occmatrix, i)), nneqlist : [], 
for i from 2 thru neqlistlen do nneqlist : 
append(nneqlist, [resultant(neqlist , neqlist , atomlist   )]), 
                                   1         i          pos
neqlist : copylist(nneqlist), neqlistlen : length(neqlist), 
atomlist : delete(atomlist   , atomlist), atomlistlen : length(atomlist), 
                          pos
for i thru neqlistlen do ([deglist, occlist] : 
get_deg_occ(neqlist , atomlist), degmatrix : addrow(degmatrix, deglist), 
                   i
occmatrix : addrow(occmatrix, occlist)), return(0))
(%i4) pdesys2pde([v,vx,vxx,vxxx],[vt,vxt],[vt-ux*vxx,utt-vt*vx-v*vxt,vxt-uxx*vxx-ux*vxxx],[ut-v*vx,uxt-vx^2-v*vxx,uxxt-3*vx*vxx-v*vxxx]);
        [ 0  0 ]
        [      ]
Start:  [ 0  0 ] 
        [      ]
        [ 0  0 ]
        [ 0  0 ]
        [      ]
Start:  [ 0  0 ] 
        [      ]
        [ 0  0 ]
(%o4)                                  0
(%i5) 

Related Help

Help for Copymatrix