It is currently Fri Sep 10, 2010 10:51 pm


All times are UTC [ DST ]


Ask on Codemiles community and get answers Free and Fast :

JAVA is a high level programming language .Here ask your JAVA questions and please help us to answer others questions.
You will find JAVA articles here.

Our guest share with us your code snippets , your programming problems , your open source projects ,read articles and post yours .







Post new topic Reply to topic  [ 1 post ] 
  Print view Previous topic | Next topic 
Author Message
 Post subject: Need help with Java Matrices using a Switch Statement
PostPosted: Tue Apr 06, 2010 5:56 am 
Offline
Newbie
User avatar

Joined: Tue Apr 06, 2010 5:50 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time

my professor gave me this design document but i don't know where to start.
if you can help me that would be great. i really do need as much help as i can possibly get. thanks. [:

Project #6 Design Document Matrix Arithmetic

Input Items
1. Data Type input I or D
2. Matrix Dimensions
a. A (m, n) input m, input n
b. B (j, k) input j, input k
3. Operation input op

Allocations & Populations
1. Create reference variables
Code:
     a.   int [ ] [ ] aIntMatrix;
    b.   int [ ][ ] bIntMatrix;
    c.   int [ ][ ] cIntMatrix;
    d.   double [ ] [ ] aDblMatrix;
    e.   double [ ][ ] bDblMatrix;
    f.   double [ ][ ] cDblMatrix;


2. Create storage space for selected input matrices (dependent upon the data type and dimensions), e.g.,
Code:
a.   int [ ] [ ] aIntMatrix = new int[m][n];
b.   int [ ][ ] bIntMatrix = new int[j][k];


3. Create storage space for selected input matrices (dependent upon the data type, operation and dimensions), e.g.,
Code:
a.   int [ ][ ] cIntMatrix = new int[m][k]; for op == “MULTIPLY”
b.   int [ ][ ] cIntMatrix = new int[m][n]; for op == “ADDITION” or “SUBTRACTION”


4. Populate the selected input arrays
Computations

1. Main
Code:
If dataType is integer Switch(op) {
Case + : { cIntMatrix = addMatrix(aIntMatrix, bIntMatrix); printMatrix(aIntMatrix); printMatrix(bIntMatrix); printMatrix(cIntMatrix); break;
}
Case - : {
}
Case * : {
}
Else
Case + : {
}
Case - : {
}
Case * : {
}
}
Switch(op) {
}

2. Methods
a. addMatrix
Code:
for(int i = 0; i < ... ; i++) for(int j = 0; j < ... ; j++)
c[ i ][ j ] = a[ i ][ j ] + b[ i ][ j ];

b. subMatrix
Code:
for(int i = 0; i < ... ; i++) for(int j = 0; j < ... ; j++)

check dimensions for A (m, n) & B (j, k) check that m == j & n == k
Code:
c[ i ][ j ] = a[ i ][ j ] - b[ i ][ j ];

c. multMatrix
Code:
for(int k = 0; k < columns of c; k++) for(int i = 0; i < rows of b; i++)
for(int j = 0; j < columns of a ; j++) c[ i ][ k ] = a[ i ][ j ] * b[ j ][ k ]


check dimensions for A (m, n) & B (j, k) check that & n == j


TOP
 Profile Send private message  
 
| More
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 


 Similar topics
 Topic title   Forum   Author   Replies 
 Java Chess  Finished Projects  msi_333  9
 Java Chat  Finished Projects  msi_333  18
 I just downloaded and installed JAVA  Java  treverly  1
 java code for decision tree algorithm  Java  PERRYS  2
 How to connect to serial port using java  Java  msi_333  9

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  





Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2009
mileX v1.0 designed by codemiles team