diff --git a/library/math/matrices.factor b/library/math/vectors.factor similarity index 60% rename from library/math/matrices.factor rename to library/math/vectors.factor index 3554c51d4a..2f3a54d558 100644 --- a/library/math/matrices.factor +++ b/library/math/vectors.factor @@ -42,27 +42,3 @@ USING: arrays generic kernel sequences ; #! Orthogonal projection of u onto v. [ [ v. ] keep norm-sq v/n ] keep n*v ; -! Matrices -: zero-matrix ( m n -- matrix ) - swap [ drop zero-array ] map-with ; - -: identity-matrix ( n -- matrix ) - #! Make a nxn identity matrix. - dup [ swap [ = 1 0 ? ] map-with ] map-with ; - -! Matrix operations -: mneg ( m -- m ) [ vneg ] map ; - -: n*m ( n m -- m ) [ n*v ] map-with ; -: m*n ( m n -- m ) swap n*m ; -: n/m ( n m -- m ) [ n/v ] map-with ; -: m/n ( m n -- m ) swap [ swap v/n ] map-with ; - -: m+ ( m m -- m ) [ v+ ] 2map ; -: m- ( m m -- m ) [ v- ] 2map ; -: m* ( m m -- m ) [ v* ] 2map ; -: m/ ( m m -- m ) [ v/ ] 2map ; - -: v.m ( v m -- v ) flip [ v. ] map-with ; -: m.v ( m v -- v ) swap [ v. ] map-with ; -: m. ( m m -- m ) flip swap [ m.v ] map-with ;