Total members 9946 | Gratitudes |It is currently Thu Feb 09, 2012 2:58 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question 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  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 Java seminar topic with demo  Java  Anonymous  1
 java project code  Java  Anonymous  0
 change Font of text in java  Java examples  msi_333  1
 Read your gmail using Java code  Java examples  msi_333  5
 project source code in java  Java  Anonymous  0

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




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-2011
mileX v1.0 designed by codemiles team