用java实现一个简单的矩阵类,可以实现简单的矩阵计算功能。
class Matrix
1.向量点乘
public static double dot(double[] x,double[] y)
2.矩阵和向量之积
public static double[] mult(double[][] a,double[] x)
3.向量和矩阵之积
public static double[] mult(double[] y,double[][] a)
4.矩阵和矩阵之积
public static double[][] mult(double[][] a,double[][] b)
5.转置矩阵
public static double[][] transpose(double[][] a)
6.打印向量
public static void printVector(double[] a)
7.打印矩阵
public static void printMatrix(double[][] a)
package com.xiaff;
public class Matrix {
//向量点乘
public static double dot(double[] x,double[] y) {
int lengthX=x.length;
int lengthY=y.length;
if(lengthX!=lengthY){
System.out.println("Cannot Dot Product!");
return 0.0;
}
double an