It presents a matrix multiplication function and provides an example of the multiplication of a 4x3 matrix by a 3x4 matrix to give a 3x3 matrix as the displayed result.
import java.util.*;
import java.io.*;
import java.text.*;
public class matrices {
void Imprimer(float a[][], int m, int n){
int i,j;
for(i=0;i<m;i++){
for(j=0;j<n;j++){
System.out.print(a[i][j]+"\t");
System.out.println("");
}
}
}
public static void main( String args[] ){
matrices M=new matrices();
float A[][]={{1,2,3,4},{5,6,7,8},{9,10,11,12}};
float B[][]={{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
float C[][]=new float [3][3];
//M.Imprimer(A,3,4);
//M.Imprimer(B,4,3);
int m=3, n=4;
int i,j,k;
for(i=0;i<m;i++)for(j=0;j<m;j++)C[i][j]=0;
for(i=0;i<m;i++)for(j=0;j<m;j++)for(k=0;k<n;k++){
C[i][j]+=A[i][k]*B[k][j];
}
M.Imprimer(C,m,m);
}
}