'("matrix.txt" loaded)

IP == (+ \)°(* aa)°trans°ee  // Inner Product

// CP == (distl aa)°distr    // Cross Product

MM == [mul] op ((IP aa)aa)°(distl aa)°distr°([0] ee trans°[1])°ee  // Matrix Multiply nach John Backus

// outerprod ° op,A,B,
outerprod == (((([2] app [1] ee [0]) aa0)°[3],id) aa0)°[1],id
// MM = outerprod ° 'IP,A,(trans°B),

droppos==((isnull°[0])->();(iszero°[1])->((tail°[0]) droppos pred°[1]);(head°[0]),(tail°[0]) droppos pred°[1])°ee  // row, i,

droprow==(droppos aa)°distr

// Laplacescher Entwicklungssatz
//  det == [det] fn ((isnull°[1])->(head°[0]);
//  	[3]°(not°isnull°[0])->*(tail°[0]),[1],([2]+'1),([3]+[4]*(head°[0])*det°[1] droprow [2]),(neg°[4]),)
//  	°head,tail,'0,'0,'1,
//      erste Zeile,ohne erste Zeile,Position,Summe,+/- Faktor

det == [det] fn ((isnull°[1])->(head°[0]);
	[3]°(not°isnull°[0])->*(tail°[0]),[1],(succ°[2]),([3] + [4] negifodd (head°[0])*det°[1] droprow [2]),(succ°[4]),)
	°head,tail,'[0],(zero°head°head),'[0],
//  erste Zeile,ohne erste Zeile,Position,Summe,+/- Faktor

Aij==(([0] droppos [1]°[1]) droprow [0]°[1])°ee  // mat Aij i,j,

//  inv == [inv] fn (([1]='0)->('[inv] error "Division by Zero";);  // trans?
//                  (((([1]°[1])*('_1 ^ +°[0])*det°([0]°[1])Aij[0]) aa)aa)°(distr aa)°((distl aa)°[2]distr[2])distr[0]ee'1/[1]
//  	)°id,det,('0,iota°pred°length),

inv == [inv] fn ((iszero°[1])->('[inv] error "Division by Zero";);  // trans?
                (((([1]°[1]) * (+°[0]) negifodd det°([0]°[1])Aij[0]) aa)aa)°(distr aa)°((distl aa)°[2]distr[2])distr[0]ee(one°[1])/[1]
	)°id,det,('[0],iota°pred°round°length),

negifodd == ((isodd°[0])->(neg°[1]);[1])°ee
ismatrix == id is 'matrix
tomatrix == 'matrix obj id

// scalar * matrix
scale == [scale] swop fail

// matrix each 'func
each == [each] op fail

// m zeromatrix n
zeromatrix == 'matrix obj (((([2] aa0)°(iota°[1]),tail) aa0)°(iota°round°[0]) ,(round°[1]),(zero°[0]),)°ee

// m onematrix n
onematrix == 'matrix obj (((([2] aa0)°(iota°[1]),tail) aa0)°(iota°round°[0]) ,(round°[1]),(one°[0]),)°ee

// idmatrix ° n
idmatrix == 'matrix obj ((((([0]=[1])->[4];[3]) aa0)°(iota°[1]),id) aa0)°(iota°round),round,zero,one,

// num like type // provisorium
like == ( (isint°[1])     -> (round°[0])
        ; (isreal°[1])    -> (float°[0])
        ; (iscomplex°[1]) -> ((float°[0]) cval 0)
        ; fail ) ° ee

matrix == .. { list
	[add] == ([1] is 'matrix) -> (((((+ aa)°trans) aa) ° trans) objdip) ; fail
	[sub] == ([1] is 'matrix) -> (((((- aa)°trans) aa) ° trans) objdip) ; fail
	[mul] == ([1] is 'matrix) -> (MM objdip) ; fail  // fail...
	[det] == det°pop
	[inv] == inv dip
	[trans] == trans dip
	[sq] == id*id
	[scale] == (isnum°[1]) -> ((top°[0]) obj ((* aa0) aa0)°(pop°[0]) ee [1]) ; fail  // scal?
	[each] == (top°[0]) obj ((([1] app [0]) aa0) aa0)°(pop°[0]) ee [1]  // name?
	[zero] == (length like [0]°[0]°pop) zeromatrix length°head
	[one] == idmatrix°(length like [0]°[0]°pop)
	}


// GNU Lesser General Public License v2.1
