public class MultiMatrix {
double[]multiplyMatrix;
public static void main(String args[]){
double[] a={12,44,188};
double[][] b={{3,5,9},{6,2,7},{1,4,8}};
MultiMatrix mm=new MultiMatrix();
mm.mMatrix(a,b);
mm.display();
}
public void mMatrix(double[] a,double[][] b){
multiplyMatrix=new double[a.length];
for (int i = 0; i<a.length; i++) {//rows of a
for (int j = 0; j<b[0].length; j++) {//columns of b
//columns of a = rows of b
multiplyMatrix[i]+=a[j]*b[j][i];
}
}
}
public void display(){
for (int i = 0; i<multiplyMatrix.length; i++) {
System.out.print(multiplyMatrix[i]+" ");
}
}
}
double[]multiplyMatrix;
public static void main(String args[]){
double[] a={12,44,188};
double[][] b={{3,5,9},{6,2,7},{1,4,8}};
MultiMatrix mm=new MultiMatrix();
mm.mMatrix(a,b);
mm.display();
}
public void mMatrix(double[] a,double[][] b){
multiplyMatrix=new double[a.length];
for (int i = 0; i<a.length; i++) {//rows of a
for (int j = 0; j<b[0].length; j++) {//columns of b
//columns of a = rows of b
multiplyMatrix[i]+=a[j]*b[j][i];
}
}
}
public void display(){
for (int i = 0; i<multiplyMatrix.length; i++) {
System.out.print(multiplyMatrix[i]+" ");
}
}
}
解决方案 »
- ==诚招Delphi程序员(上海)2名
- treeview定位问题
- 只开通 80端口上网的电脑,怎样让他实现可以通过代理服务器连接上 SQL 服务器.
- 关于MEMO控件的问题
- 看看这个问题
- 在adoquery中,每当指向记录的指针发生变化时就触发某事件的代码该如何写
- 有什么 DBgrid 控件可以把 横着排 的数据变成 竖排
- 200分求酒店房间分布图的解决方案,ListView很麻烦,自己要写很多代码控制。
- 在中国,用什么方法注册软件最方便?用户最容易接受? 是银行转帐,邮寄,还是其它?
- "table is busy" 如何解决
- delphiXE中如何显示access中的word文档
- xe 下的触控图片旋转缩放问题
function m(a:TDoubleDynArray; b: array of TDoubleDynArray): TDoubleDynArray;
var
I, J: Integer;
begin
SetLength(Result, Length(a));
for I:=0 to High(a) do
begin
Result[I] := 0;
for J:=0 to High(b) do
Result[I] := Result[I] + a[J]*b[J][I]
end;
end;{调用}
procedure TForm1.Button1Click(Sender: TObject);
var
a:TDoubleDynArray;
b: array of TDoubleDynArray;
r: TDoubleDynArray;
I: Integer;
begin
SetLength(a, 3);
a[0]:=12;a[1]:=44;a[2]:=188; SetLength(b, 3);
for I:=0 to High(b) do
SetLength(b[I], 3);
b[0][0]:=3;b[0][1]:=5;b[0][2]:=9;
b[1][0]:=6;b[1][1]:=2;b[1][2]:=7;
b[2][0]:=1;b[2][1]:=4;b[2][2]:=8; r := m(a, b);
showmessagefmt('%f,%f,%f', [r[0],r[1],r[2]])
end;