symatvec.red 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. module symatvec;
  2. % Symmetry
  3. % Author : Karin Gatermann
  4. % Konrad-Zuse-Zentrum fuer
  5. % Informationstechnik Berlin
  6. % Heilbronner Str. 10
  7. % W-1000 Berlin 31
  8. % Germany
  9. % Email: Gatermann@sc.ZIB-Berlin.de
  10. % symatvec.red
  11. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  12. %
  13. % functions for matrix vector operations
  14. %
  15. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  16. symbolic procedure gen!+can!+bas(dimension);
  17. % returns the canonical basis of R^dimension as a vector list
  18. begin
  19. scalar eins,nullsq,i,j,ll;
  20. eins:=(1 ./ 1);
  21. nullsq:=(nil ./ 1);
  22. ll:= for i:=1:dimension collect
  23. for j:=1:dimension collect
  24. if i=j then eins else nullsq;
  25. return ll;
  26. end;
  27. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  28. %
  29. % matrix functions
  30. %
  31. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  32. symbolic procedure alg!+matrix!+p(mat1);
  33. % returns true if the matrix is a matrix from algebraic level
  34. begin
  35. scalar len,elem;
  36. if length(mat1)<1 then rederr("should be a matrix");
  37. if not(car (mat1) = 'mat) then rederr("should be a matrix");
  38. mat1:=cdr mat1;
  39. if length(mat1)<1 then rederr("should be a matrix");
  40. len:=length(car mat1);
  41. for each elem in cdr mat1 do
  42. if not(length(elem)=len) then rederr("should be a matrix");
  43. return t;
  44. end;
  45. symbolic procedure matrix!+p(mat1);
  46. % returns true if the matrix is a matrix in internal structure
  47. begin
  48. scalar dimension,z,res;
  49. if length(mat1)<1 then return nil;
  50. dimension:=length(car mat1);
  51. res:=t;
  52. for each z in cdr mat1 do
  53. if not(dimension = length(z)) then res:=nil;
  54. return res;
  55. end;
  56. symbolic procedure squared!+matrix!+p(mat1);
  57. % returns true if the matrix is a matrix in internal structure
  58. begin
  59. if (matrix!+p(mat1) and (get!+row!+nr(mat1) = get!+col!+nr(mat1)))
  60. then return t;
  61. end;
  62. symbolic procedure equal!+matrices!+p(mat1,mat2);
  63. % returns true if the matrices are equal ( internal structure)
  64. begin
  65. scalar s,z,helpp,mathelp,sum,rulesum,rule1,rule2;
  66. if (same!+dim!+squared!+p(mat1,mat2)) then
  67. <<
  68. mathelp:=
  69. mk!+mat!+plus!+mat(mat1,
  70. mk!+scal!+mult!+mat((-1 ./ 1),mat2));
  71. sum:=(nil ./ 1);
  72. for each z in mathelp do
  73. for each s in z do
  74. if !*complex then
  75. sum:=addsq(sum,multsq(s,mk!+conjugate!+sq s)) else
  76. sum:=addsq(sum,multsq(s,s));
  77. % print!-sq(sum);
  78. rulesum:=change!+sq!+to!+algnull(sum);
  79. if rulesum = 0 then helpp:=t else helpp:=nil;
  80. % print!-sq(simp rulesum);
  81. % if null(numr(simp prepsq(sum))) then helpp:=t
  82. % else helpp:=nil;
  83. >> else helpp:=nil;
  84. return helpp;
  85. end;
  86. symbolic procedure get!+row!+nr(mat1);
  87. % returns the number of rows
  88. begin
  89. return length(mat1);
  90. end;
  91. symbolic procedure get!+col!+nr(mat1);
  92. % returns the number of columns
  93. begin
  94. return length(car mat1);
  95. end;
  96. symbolic procedure get!+mat!+entry(mat1,z,s);
  97. % returns the matrix element in row z and column s
  98. begin
  99. return nth(nth(mat1,z),s);
  100. end;
  101. symbolic procedure same!+dim!+squared!+p(mat1,mat2);
  102. % returns true if the matrices are both squared matrices
  103. % of the same dimension
  104. % (internal structur)
  105. begin
  106. if (squared!+matrix!+p(mat1) and squared!+matrix!+p(mat2) and
  107. (get!+row!+nr(mat1) = get!+row!+nr(mat1)))
  108. then return t;
  109. end;
  110. symbolic procedure mk!+transpose!+matrix(mat1);
  111. % returns the transposed matrix (internal structure)
  112. begin
  113. scalar z,s,tpmat1;
  114. if not(matrix!+p(mat1)) then rederr("no matrix in transpose");
  115. tpmat1:=for z:=1:get!+col!+nr(mat1) collect
  116. for s:=1:get!+row!+nr(mat1) collect
  117. get!+mat!+entry(mat1,s,z);
  118. return tpmat1
  119. end;
  120. symbolic procedure mk!+conjugate!+matrix(mat1);
  121. % returns the matrix with conjugate elements (internal structure)
  122. begin
  123. scalar z,s,tpmat1;
  124. if not(matrix!+p(mat1)) then rederr("no matrix in conjugate matrix");
  125. tpmat1:=for z:=1:get!+row!+nr(mat1) collect
  126. for s:=1:get!+col!+nr(mat1) collect
  127. mk!+conjugate!+sq(get!+mat!+entry(mat1,z,s));
  128. return tpmat1
  129. end;
  130. symbolic procedure mk!+hermitean!+matrix(mat1);
  131. % returns the transposed matrix (internal structure)
  132. begin
  133. if !*complex then
  134. return mk!+conjugate!+matrix(mk!+transpose!+matrix(mat1)) else
  135. return mk!+transpose!+matrix(mat1);
  136. end;
  137. symbolic procedure unitarian!+p(mat1);
  138. % returns true if matrix is orthogonal or unitarian resp.
  139. begin
  140. scalar mathermit,unitmat1;
  141. mathermit:=mk!+mat!+mult!+mat(mk!+hermitean!+matrix(mat1),mat1);
  142. unitmat1:=mk!+unit!+mat(get!+row!+nr(mat1));
  143. if equal!+matrices!+p(mathermit,unitmat1) then return t;
  144. end;
  145. symbolic procedure mk!+mat!+mult!+mat(mat1,mat2);
  146. % returns a matrix= matrix1*matrix2 (internal structure)
  147. begin
  148. scalar dims1,dimz1,dims2,s,z,res,sum,k;
  149. if not(matrix!+p(mat1)) then rederr("no matrix in mult");
  150. if not(matrix!+p(mat2)) then rederr("no matrix in mult");
  151. dims1:=get!+col!+nr(mat1);
  152. dimz1:=get!+row!+nr(mat1);
  153. dims2:=get!+col!+nr( mat2);
  154. if not(dims1 = get!+row!+nr(mat2)) then
  155. rederr("matrices can not be multiplied");
  156. res:=for z:=1:dimz1 collect
  157. for s:=1:dims2 collect
  158. <<
  159. sum:=(nil ./ 1);
  160. for k:=1:dims1 do
  161. sum:=addsq(sum,
  162. multsq(
  163. get!+mat!+entry(mat1,z,k),
  164. get!+mat!+entry(mat2,k,s)
  165. )
  166. );
  167. sum:=subs2 sum where !*sub2=t;
  168. sum
  169. >>;
  170. return res;
  171. end;
  172. symbolic procedure mk!+mat!+plus!+mat(mat1,mat2);
  173. % returns a matrix= matrix1 + matrix2 (internal structure)
  174. begin
  175. scalar dims,dimz,s,z,res,sum;
  176. if not(matrix!+p(mat1)) then rederr("no matrix in add");
  177. if not(matrix!+p(mat2)) then rederr("no matrix in add");
  178. dims:=get!+col!+nr(mat1);
  179. dimz:=get!+row!+nr(mat1);
  180. if not(dims = get!+col!+nr(mat2)) then
  181. rederr("wrong dimensions in add");
  182. if not(dimz = get!+row!+nr(mat2)) then
  183. rederr("wrong dimensions in add");
  184. res:=for z:=1:dimz collect
  185. for s:=1:dims collect
  186. <<
  187. sum:=addsq(
  188. get!+mat!+entry(mat1,z,s),
  189. get!+mat!+entry(mat2,z,s)
  190. );
  191. sum:=subs2 sum where !*sub2=t;
  192. sum
  193. >>;
  194. return res;
  195. end;
  196. symbolic procedure mk!+mat!*mat!*mat(mat1,mat2,mat3);
  197. % returns a matrix= matrix1*matrix2*matrix3 (internal structure)
  198. begin
  199. scalar res;
  200. res:= mk!+mat!+mult!+mat(mat1,mat2);
  201. return mk!+mat!+mult!+mat(res,mat3);
  202. end;
  203. symbolic procedure add!+two!+mats(mat1,mat2);
  204. % returns a matrix=( matrix1, matrix2 )(internal structure)
  205. begin
  206. scalar dimz,z,res;
  207. if not(matrix!+p(mat1)) then rederr("no matrix in add");
  208. if not(matrix!+p(mat2)) then rederr("no matrix in add");
  209. dimz:=get!+row!+nr(mat1);
  210. if not(dimz = get!+row!+nr(mat2)) then rederr("wrong dim in add");
  211. res:=for z:=1:dimz collect
  212. append(nth(mat1,z),nth(mat2,z));
  213. return res;
  214. end;
  215. symbolic procedure mk!+scal!+mult!+mat(scal1,mat1);
  216. % returns a matrix= scalar*matrix (internal structure)
  217. begin
  218. scalar res,z,s,prod;
  219. if not(matrix!+p(mat1)) then rederr("no matrix in add");
  220. res:=for each z in mat1 collect
  221. for each s in z collect
  222. <<
  223. prod:=multsq(scal1,s);
  224. prod:=subs2 prod where !*sub2=t;
  225. prod
  226. >>;
  227. return res;
  228. end;
  229. symbolic procedure mk!+trace(mat1);
  230. % returns the trace of the matrix (internal structure)
  231. begin
  232. scalar spurx,s;
  233. if not(squared!+matrix!+p(mat1)) then
  234. rederr("no square matrix in add");
  235. spurx :=(nil ./ 1);
  236. for s:=1:get!+row!+nr(mat1) do
  237. spurx :=addsq(spurx,get!+mat!+entry(mat1,s,s));
  238. spurx :=subs2 spurx where !*sub2=t;
  239. return spurx
  240. end;
  241. symbolic procedure mk!+block!+diagonal!+mat(mats);
  242. % returns a blockdiagonal matrix from
  243. % a list of matrices (internal structure)
  244. begin
  245. if length(mats)<1 then rederr("no list in mkdiagonalmats");
  246. if length(mats)=1 then return car mats else
  247. return fill!+zeros(car mats,mk!+block!+diagonal!+mat(cdr(mats)));
  248. end;
  249. symbolic procedure fill!+zeros(mat1,mat2);
  250. % returns a blockdiagonal matrix from 2 matrices (internal structure)
  251. begin
  252. scalar nullmat1,nullmat2;
  253. nullmat1:=mk!+null!+mat(get!+row!+nr(mat2),get!+col!+nr(mat1));
  254. nullmat2:=mk!+null!+mat(get!+row!+nr(mat1),get!+col!+nr(mat2));
  255. return append(add!+two!+mats(mat1,nullmat2),
  256. add!+two!+mats(nullmat1,mat2));
  257. end;
  258. symbolic procedure mk!+outer!+mat(innermat);
  259. % returns a matrix for algebraic level
  260. begin
  261. scalar res,s,z;
  262. if not(matrix!+p(innermat)) then rederr("no matrix in mkoutermat");
  263. res:= for each z in innermat collect
  264. for each s in z collect
  265. prepsq s;
  266. return append(list('mat),res);
  267. end;
  268. symbolic procedure mk!+inner!+mat(outermat);
  269. % returns a matrix in internal structure
  270. begin
  271. scalar res,s,z;
  272. res:= for each z in cdr outermat collect
  273. for each s in z collect
  274. simp s;
  275. if matrix!+p(res) then return res else
  276. rederr("incorrect input in mkinnermat");
  277. end;
  278. symbolic procedure mk!+resimp!+mat(innermat);
  279. % returns a matrix in internal structure
  280. begin
  281. scalar res,s,z;
  282. res:= for each z in innermat collect
  283. for each s in z collect
  284. resimp s;
  285. return res;
  286. end;
  287. symbolic procedure mk!+null!+mat(dimz,dims);
  288. % returns a matrix of zeros in internal structure
  289. begin
  290. scalar nullsq,s,z,res;
  291. nullsq:=(nil ./ 1);
  292. res:=for z:=1:dimz collect
  293. for s:=1:dims collect nullsq;
  294. return res;
  295. end;
  296. symbolic procedure mk!+unit!+mat(dimension);
  297. % returns a squared unit matrix in internal structure
  298. begin
  299. return gen!+can!+bas(dimension);
  300. end;
  301. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  302. %
  303. % vector functions
  304. %
  305. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  306. symbolic procedure vector!+p(vector1);
  307. % returns the length of a vector
  308. % vector -- list of sqs
  309. begin
  310. if length(vector1)>0 then return t;
  311. end;
  312. symbolic procedure get!+vec!+dim(vector1);
  313. % returns the length of a vector
  314. % vector -- list of sqs
  315. begin
  316. return length(vector1);
  317. end;
  318. symbolic procedure get!+vec!+entry(vector1,elem);
  319. % returns the length of a vector
  320. % vector -- list of sqs
  321. begin
  322. return nth(vector1,elem);
  323. end;
  324. symbolic procedure mk!+mat!+mult!+vec(mat1,vector1);
  325. % returns a vector= matrix*vector (internal structure)
  326. begin
  327. scalar z;
  328. return for each z in mat1 collect
  329. mk!+real!+inner!+product(z,vector1);
  330. end;
  331. symbolic procedure mk!+scal!+mult!+vec(scal1,vector1);
  332. % returns a vector= scalar*vector (internal structure)
  333. begin
  334. scalar entry,res,h;
  335. res:=for each entry in vector1 collect
  336. <<
  337. h:=multsq(scal1,entry);
  338. h:=subs2 h where !*sub2=t;
  339. h
  340. >>;
  341. return res;
  342. end;
  343. symbolic procedure mk!+vec!+add!+vec(vector1,vector2);
  344. % returns a vector= vector1+vector2 (internal structure)
  345. begin
  346. scalar ent,res,h;
  347. res:=for ent:=1:get!+vec!+dim(vector1) collect
  348. <<
  349. h:= addsq(get!+vec!+entry(vector1,ent),
  350. get!+vec!+entry(vector2,ent));
  351. h:=subs2 h where !*sub2=t;
  352. h
  353. >>;
  354. return res;
  355. end;
  356. symbolic procedure mk!+squared!+norm(vector1);
  357. % returns a scalar= sum vector_i^2 (internal structure)
  358. begin
  359. return mk!+inner!+product(vector1,vector1);
  360. end;
  361. symbolic procedure my!+nullsq!+p(scal);
  362. % returns true, if ths sq is zero
  363. begin
  364. if null(numr( scal)) then return t;
  365. end;
  366. symbolic procedure mk!+null!+vec(dimen);
  367. % returns a vector of zeros
  368. begin
  369. scalar nullsq,i,res;
  370. nullsq:=(nil ./ 1);
  371. res:=for i:=1:dimen collect nullsq;
  372. return res;
  373. end;
  374. symbolic procedure mk!+conjugate!+vec(vector1);
  375. % returns a vector of zeros
  376. begin
  377. scalar z,res;
  378. res:=for each z in vector1 collect mk!+conjugate!+sq(z);
  379. return res;
  380. end;
  381. symbolic procedure null!+vec!+p(vector1);
  382. % returns a true, if vector is the zero vector
  383. begin
  384. if my!+nullsq!+p(mk!+squared!+norm(vector1)) then
  385. return t;
  386. end;
  387. symbolic procedure mk!+normalize!+vector(vector1);
  388. % returns a normalized vector (internal structure)
  389. begin
  390. scalar scalo,vecres;
  391. scalo:=simp!* {'sqrt, mk!*sq(mk!+squared!+norm(vector1))};
  392. if my!+nullsq!+p(scalo) then
  393. vecres:= mk!+null!+vec(get!+vec!+dim(vector1)) else
  394. <<
  395. scalo:=simp prepsq scalo;
  396. scalo:=quotsq((1 ./ 1),scalo);
  397. vecres:= mk!+scal!+mult!+vec(scalo,vector1);
  398. >>;
  399. return vecres;
  400. end;
  401. symbolic procedure mk!+inner!+product(vector1,vector2);
  402. % returns the inner product of vector1 and vector2 (internal structure)
  403. begin
  404. scalar z,sum,vec2;
  405. if not(get!+vec!+dim(vector1) = get!+vec!+dim(vector2)) then
  406. rederr("wrong dimensions in innerproduct");
  407. sum:=(nil ./ 1);
  408. if !*complex then vec2:=mk!+conjugate!+vec(vector2) else
  409. vec2:=vector2;
  410. for z:=1:get!+vec!+dim(vector1) do
  411. sum:=addsq(sum,multsq(
  412. get!+vec!+entry(vector1,z),
  413. get!+vec!+entry(vec2,z)
  414. )
  415. );
  416. sum:=subs2 sum where !*sub2=t;
  417. return sum;
  418. end;
  419. symbolic procedure mk!+real!+inner!+product(vector1,vector2);
  420. % returns the inner product of vector1 and vector2 (internal structure)
  421. begin
  422. scalar z,sum;
  423. if not(get!+vec!+dim(vector1) = get!+vec!+dim(vector2)) then
  424. rederr("wrong dimensions in innerproduct");
  425. sum:=(nil ./ 1);
  426. for z:=1:get!+vec!+dim(vector1) do
  427. sum:=addsq(sum,multsq(
  428. get!+vec!+entry(vector1,z),
  429. get!+vec!+entry(vector2,z)
  430. )
  431. );
  432. sum:=subs2 sum where !*sub2=t;
  433. return sum;
  434. end;
  435. symbolic procedure mk!+Gram!+Schmid(vectorlist,vector1);
  436. % returns a vectorlist of orthonormal vectors
  437. % assumptions: vectorlist is orthonormal basis, internal structure
  438. begin
  439. scalar i,orthovec,scalo,vectors1;
  440. orthovec:=vector1;
  441. for i:=1:(length(vectorlist)) do
  442. <<
  443. scalo:= negsq(mk!+inner!+product(orthovec,nth(vectorlist,i)));
  444. orthovec:=mk!+vec!+add!+vec(orthovec,
  445. mk!+scal!+mult!+vec(scalo,nth(vectorlist,i)));
  446. >>;
  447. orthovec:=mk!+normalize!+vector(orthovec);
  448. if null!+vec!+p(orthovec) then
  449. vectors1:=vectorlist else
  450. vectors1:=add!+vector!+to!+list(orthovec,vectorlist);
  451. return vectors1
  452. end;
  453. symbolic procedure Gram!+Schmid(vectorlist);
  454. % returns a vectorlist of orthonormal vectors
  455. begin
  456. scalar ortholist,i;
  457. if length(vectorlist)<1 then rederr("error in Gram Schmid");
  458. if vector!+p(car vectorlist) then
  459. ortholist:=nil
  460. else rederr("strange in Gram-Schmid");
  461. for i:=1:length(vectorlist) do
  462. ortholist:=mk!+Gram!+Schmid(ortholist,nth(vectorlist,i));
  463. return ortholist;
  464. end;
  465. symbolic procedure add!+vector!+to!+list(vector1,vectorlist);
  466. % returns a list of vectors consisting of vectorlist
  467. % and the vector1 at the end
  468. % internal structure
  469. begin
  470. return append(vectorlist,list(vector1));
  471. end;
  472. symbolic procedure mk!+internal!+mat(vectorlist);
  473. % returns a matrix consisting of columns
  474. % equal to the vectors in vectorlist
  475. % internal structure
  476. begin
  477. return mk!+transpose!+matrix(vectorlist);
  478. end;
  479. symbolic procedure mat!+veclist(mat1);
  480. % returns a vectorlist consisting of the columns of the matrix
  481. % internal structure
  482. begin
  483. return mk!+transpose!+matrix(mat1);
  484. end;
  485. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  486. %
  487. % some useful functions
  488. %
  489. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  490. symbolic procedure change!+sq!+to!+int(scal1);
  491. % scal1 -- sq which is an integer
  492. % result is a nonnegative integer
  493. begin
  494. scalar nr;
  495. nr:=simp!* prepsq scal1;
  496. if (denr(nr) = 1) then return numr(nr) else
  497. rederr("no integer in change!+sq!+to!+int");
  498. end;
  499. symbolic procedure change!+int!+to!+sq(scal1);
  500. % scal1 -- integer for example 1 oder 2 oder 3
  501. % result is a sq
  502. begin
  503. return (scal1 ./ 1);
  504. end;
  505. symbolic procedure change!+sq!+to!+algnull(scal1);
  506. begin
  507. scalar rulesum,storecomp;
  508. if !*complex then
  509. <<
  510. storecomp:=t;
  511. off complex;
  512. >> else
  513. <<
  514. storecomp:=nil;
  515. >>;
  516. rulesum:=evalwhereexp ({'(list (list
  517. (REPLACEBY
  518. (COS (!~ X))
  519. (TIMES
  520. (QUOTIENT 1 2)
  521. (PLUS (EXPT E (TIMES I (!~ X))) (EXPT E (MINUS (TIMES I (!~ X))))) ))
  522. (REPLACEBY
  523. (SIN (!~ X))
  524. (TIMES
  525. (QUOTIENT 1 (times 2 i))
  526. (difference (EXPT E (TIMES I (!~ X)))
  527. (EXPT E (MINUS (TIMES I (!~ X))))) ))
  528. ))
  529. , prepsq(scal1)});
  530. rulesum:=reval rulesum;
  531. if storecomp then on complex;
  532. % print!-sq(simp (rulesum));
  533. return rulesum;
  534. end;
  535. symbolic procedure mk!+conjugate!+sq(mysq);
  536. begin
  537. return conjsq(mysq);
  538. % return subsq(mysq,'(( i . (minus i))));
  539. end;
  540. symbolic procedure mk!+equation(arg1,arg2);
  541. begin
  542. return list('equal,arg1,arg2);
  543. end;
  544. symbolic procedure outer!+equation!+p(outerlist);
  545. begin
  546. if eqcar(outerlist, 'equal) then return t
  547. end;
  548. symbolic procedure mk!+outer!+list(innerlist);
  549. begin
  550. return append (list('list),innerlist)
  551. end;
  552. symbolic procedure mk!+inner!+list(outerlist);
  553. begin
  554. if outer!+list!+p(outerlist) then return cdr outerlist;
  555. end;
  556. symbolic procedure outer!+list!+p(outerlist);
  557. begin
  558. if eqcar(outerlist, 'list) then return t
  559. end;
  560. symbolic procedure equal!+lists!+p(ll1,ll2);
  561. begin
  562. return (list!+in!+list!+p(ll1,ll2) and list!+in!+list!+p(ll2,ll1));
  563. end;
  564. symbolic procedure list!+in!+list!+p(ll1,ll2);
  565. begin
  566. if length(ll1)=0 then return t else
  567. return (memq(car ll1,ll2) and list!+in!+list!+p(cdr ll1,ll2));
  568. end;
  569. symbolic procedure print!-matrix(mat1);
  570. begin
  571. writepri (mkquote mk!+outer!+mat(mat1),'only);
  572. end;
  573. symbolic procedure print!-sq(mysq);
  574. begin
  575. writepri (mkquote prepsq(mysq),'only);
  576. end;
  577. endmodule;
  578. end;