Sample patches for Matrix.sc ( // newClear creation var matrix; matrix = Matrix.newClear(3,3); matrix.postln; ) ( // with creation var matrix; matrix = Matrix.with([[1,2],[3,4],[5,6]]); matrix.postln; ) ( // withFlatArray creation var matrix; matrix = Matrix.withFlatArray(3,3,[1,2,3,4,5,6,7,8,9]); matrix.postln; ) ( // newIdentity creation var matrix; matrix = Matrix.newIdentity(3,3); matrix.postln; ) ( // getting rows and cols var matrix; matrix = Matrix.with([[1,2,3],[4,5,6],[7,8,9]]); matrix.postln; matrix.rows.postln; matrix.cols.postln; ) ( // using put and at var matrix; matrix = Matrix.newClear(3,3); //matrix.dump; matrix.postln; matrix.put(2,1,3).postln; matrix.at(2,1).postln; ) ( // using putRow, putCol, fillRow, fillCol and flop var matrix; matrix = Matrix.newClear(3,3); matrix.postln; matrix.putRow(2,[1,2,3]).postln; matrix.putCol(2,[4,4,4]).postln; matrix = matrix.flop.postln; matrix.fillRow(0,{3}).postln; matrix.fillCol(1,4).postln; ) ( // using fromRow vs. getRow, removeRow, sub var matrix; matrix = Matrix.with([[1,2,3],[4,5,6],[7,8,9]]); matrix.fromRow(0).post; "returns a matrix".postln; matrix.getRow(0).post; "returns an array".postln; matrix.removeRow(0).postln; matrix.sub(0,0).postln; matrix.sub(2,0).postln; ) ( // using * on matrices var matrix1, matrix2; matrix1 = Matrix.with([[1,4,3]]); matrix2 = Matrix.with([[4],[4],[1]]); (matrix1 * matrix2).postln; (matrix2 * matrix1).postln; ) ( // using * , inverse var matrix1, matrix2, m1m2, m2m1; matrix1 = Matrix.with([[1,3,3],[2,0,5],[2,1,1]]); matrix2 = Matrix.with([[1,2,2],[2,1,1],[1,0,1]]); m1m2 = (matrix1 * matrix2).postln; m2m1 = (matrix2 * matrix1).postln; (m1m2 * m2m1).postln; (m1m2 * m1m2.inverse).postln; "should return the identety matrix".post; Matrix.newIdentity(3,3).postln; ) ( // det ,trace ; var matrix; matrix = Matrix.with([[1,2],[3,4]]); matrix.postln; matrix.det.postln; matrix.trace.postln; ) ( // using unary and binary operators var matrix; matrix = Matrix.with([[1.3,2.5,3.7],[-6,0,-2],[2,-1,2]]); matrix.postln; (matrix / 3).postln; (matrix + 2.1).postln; (matrix - 3).postln; (matrix * 3).postln; (matrix ** 3).postln; (matrix.ceil(3)).postln; (matrix.neg).postln; (matrix.abs).postln; (matrix.sign).postln; (matrix.min(3)).postln; ) ( // testing var matrix1, matrix2; matrix1 = Matrix.newIdentity(3,3); matrix2 = Matrix.with([[1,2,3],[4,5,6],[7,8,9]]); " matrix1".post; matrix1.postln; "isSquare ".post; matrix1.isSquare.postln; "isSingular ".post; matrix1.isSingular.postln; "isRegular ".post; matrix1.isRegular.postln; "isSymmetric ".post; matrix1.isSymmetric.postln; "isAntiSymmetric ".post; matrix1.isAntiSymmetric.postln; "isPositive ".post; matrix1.isPositive.postln; "isNonNegative ".post; matrix1.isNonNegative.postln; "isNormal ".post; matrix1.isNormal.postln; "isZero ".post; matrix1.isZero.postln; "isIntegral ".post; matrix1.isIntegral.postln; "isIdentity ".post; matrix1.isIdentity.postln; "isDiagonal ".post; matrix1.isDiagonal.postln; "isOrthogonal ".post; matrix1.isOrthogonal.postln; "isIdempotent ".post; matrix1.isIdempotent.postln; " matrix2".post; matrix2.postln; "isSquare ".post; matrix2.isSquare.postln; "isSingular ".post; matrix2.isSingular.postln; "isRegular ".post; matrix2.isRegular.postln; "isSymmetric ".post; matrix2.isSymmetric.postln; "isAntiSymmetric ".post; matrix2.isAntiSymmetric.postln; "isPositive ".post; matrix2.isPositive.postln; "isNonNegative ".post; matrix2.isNonNegative.postln; "isNormal ".post; matrix2.isNormal.postln; "isZero ".post; matrix2.isZero.postln; "isIntegral ".post; matrix2.isIntegral.postln; "isIdentity ".post; matrix2.isIdentity.postln; "isDiagonal ".post; matrix2.isDiagonal.postln; "isOrthogonal ".post; matrix2.isOrthogonal.postln; "isIdempotent ".post; matrix2.isIdempotent.postln; )