Multidimarrays

Multidimarrays - for(int a = 0; a < n; a++ ) {...

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

View Full Document Right Arrow Icon
//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];
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
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

This note was uploaded on 09/28/2011 for the course CS 2133 taught by Professor Rao during the Fall '10 term at Oklahoma State.

Page1 / 2

Multidimarrays - for(int a = 0; a < n; a++ ) {...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online