{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Multidimarrays

# Multidimarrays - for(int a = 0 a< n a for(int b = 0...

This preview shows pages 1–2. Sign up to view the full content.

//Matt Hergenrether //CS 2133 //February 25, 2009 public class Multidimarrays { //declaring variables public int m; public int n; public int p; public double [] [] L; public double [] [] R; public double [] [] X; public boolean fail = false; public Multidimarrays() { //initiates public ints m = 0; n = 0; p = 0; } //constructor: brings in data from program that calls it and assigns variables values public Multidimarrays(int leftRow, int leftCol, int rightRow, int rightCol, double[] [] Left, double[] [] Right) { if(leftCol == rightRow) { m = leftRow; n = leftCol; p = rightCol; L = new double [m][n]; R = new double [n][p]; X = new double [m][p];

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for(int a = 0; a < n; a++ ) { for(int b = 0; b<m; b++) { L[b][a] = Left[b][a]; } for(int c = 0; c<p; c++) { R[a][c] =Right[a][c]; } } } else { //will cause the program to return null if it is true fail = true; } } public double mult() { if(fail) { return null; } else { for(int i = 0; i < m; i++ ) { for(int j = 0; j<p; j++) { for(int k = 0; k<n; k++) { //does the summation and multiplication that the problem required X[i][j] = X[i][j] + L[i][k] * R[k][j]; //does the summation and multiplication that the problem required } } } return X; } } }...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

Multidimarrays - for(int a = 0 a< n a for(int b = 0...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online