1/* 2 Some utilities for working with vectors. 3 4 Copyright (C) Nov. 2008 Volker van Nek 5 6 For examples see vector_rebuild.usg . 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21 MA 02110-1301, USA. 22*/ 23 24eval_when([translate,batch,demo,load], load("vector_rebuild.lisp"))$ 25 26eval_when([batch,demo,load], ttyoff:true)$ 27 28listarith: false$ 29doallmxops: false$ 30domxmxops: false$ 31 32dotexptsimp: false$ 33/* dotexptsimp: false avoids the following (same for matrices): 34(%i1) (listarith: false, x: [1,2].[1,2], listarith: true, ev(x)); 35(%o1) [ 5 ] 36*/ 37 38domxplus: false$ /* default */ 39scalarmatrixp: true$ /* default */ 40mx0simp: true$ /* default, if false then 0*matrix([1,2]); --> 0 */ 41 42/* 1. define mtimesq (vector_rebuild.lisp) 43 2. set listarith & friends 44 3. then we are ready for tellsimpafter 45*/ 46ttyoff: true$ 47lsmx_or_abs1_p(x):= 48 is( listp(x) or matrixp(x) or is(equal(abs(x),1))=true )$ 49matchdeclare( 50 nlsmx, lambda([x], not lsmx_or_abs1_p(x)), 51 tmsq, ?mtimesqp, 52 lsmx, lambda([x],listp(x) or matrixp(x)) )$ 53simp:false$ 54tellsimpafter( 55 nlsmx*tmsq, 56 buildq([nlm:nlsmx, tq1:args(tmsq)[1], tq2:args(tmsq)[2]], 57 nlm*tq1 ?mtimesq tq2) )$ 58tellsimpafter( 59 nlsmx*lsmx, buildq([nlm:nlsmx, lm:lsmx], nlm ?mtimesq lm) )$ 60tellsimpafter( 61 (-1)*nlsmx*lsmx, buildq([nlm:nlsmx, lm:lsmx], - nlm ?mtimesq lm) )$ 62tellsimpafter( 63 (-1)*lsmx, buildq([lm:lsmx], - lm) )$ 64simp:true$ 65ttyoff: false$ 66 67/* 2 lines copied from share/matrix/eigen.mac: */ 68columnvector(x):=transpose(matrix(x))$ 69covect(x):=columnvector(x)$ 70 71eval_when([batch,demo,load], ttyoff:false)$ 72