使用的是flanagan包
例子中的2个矩阵相乘
首先创建2个double类型的二维数组
用new Matrix(double[][]);构造吧二维数组转换成Matrix 利用times方法进行乘法
代码如下:
/** * Test.java * com.xin.test * * Function: TODO * * ver date author * ────────────────────────────────── * 2010-9-6 胡迪新 * * Copyright (c) 2010, Firsthuida All Rights Reserved. */ package com.xin.test; import flanagan.math.Matrix; /** * ClassName:Test * Function: TODO ADD FUNCTION * Reason: TODO ADD REASON * * @author 胡迪新 * @version * @since Ver 1.1 * @Date 2010-9-6 下午02:20:02 * * @see */ public class Test { public static void main(String[] args) { double[][] arraysA = {{1,2,3,4,5,6}}; double[][] arraysB = {{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5}}; double[][] arraysC = new double[1][5]; Matrix matrixA = new Matrix(arraysA); Matrix matrixB = new Matrix(arraysB); Matrix matrixC = new Matrix(1,5); matrixC = matrixA.times(matrixB); arraysC = matrixC.getArrayCopy(); for(int i=0; i<1; i++){ for(int j=0; j<5; j++){ System.out.print(arraysC[i][j]+"/t"); } System.out.println(" "); } System.out.println(" "); } }