Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


apurva kale
programm
1 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


WAP to Multiplication of matrix in the way if we have the 3*3 matrix then the we create a 4 thread. In 1 thread mul of 1 row and 1,2,3 coloume.In 2 thread mul of 2 row and 1,2,3 coloume In 3 thread mul of 3 row and 1,2,3 coloume and in 4 thread whole mul of two matrix

Matrix 1 : | 1 2 3| | 4 5 6| | 7 8 9| Matrix 2 : |9 8 7| |6 5 4| |3 2 1|

|9+12+9 8+10+6+ 7+8+3 |:thread:1 |36+30+18 32+25+12 28+20+6 |:thread:2 |63+48+27 56+40+18 49+32+9 |:thread:3

Mul of both matrix :and whole mul of two matrix as thread 4 |30 24 18| |84 69 54| |138 114 90|


Advertisement
View Answers

February 21, 2011 at 12:36 PM


Java Matrix Multiplication

import java.util.*;
class MatrixMultiplication{

    public static void main(String[] args){
    Scanner input = new Scanner(System.in);
    int[][] A = new int[3][3];
int[][] B = new int[3][3];
int[][] C = new int[3][3];
System.out.println("Enter elements for matrix A : ");
for (int i=0 ; i < A.length ; i++)
for  (int j=0 ; j < A[i].length ; j++){
A[i][j] = input.nextInt();
}
System.out.println("Enter elements for matrix B : ");
for (int i=0 ; i < B.length ; i++)
for  (int j=0 ; j < B[i].length ; j++){
B[i][j] = input.nextInt();
}
System.out.println("Matrix A: ");
        for (int i=0 ; i < A.length ; i++){
            System.out.println();
            for  (int j=0 ; j < A[i].length ; j++){
                System.out.print(A[i][j]+" ");
                  }
        }
System.out.println();
System.out.println();
System.out.println("Matrix B: ");
        for (int i=0 ; i < B.length ; i++){    
            System.out.println();
            for  (int j=0 ; j < B[i].length ; j++){
                System.out.print(B[i][j]+" ");
                  }
        }
System.out.println();
System.out.println();
System.out.println("Result is: ");
System.out.println();

for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
C[i][j]+=A[i][k]*B[k][j];
}
}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
System.out.print(+C[i][j]+" ");
}
System.out.println();
} 
}
}


Related Tutorials/Questions & Answers:
write a programm using java
write a programm using java  print the following using java programming
Advertisements
menu drive programm in java
menu drive programm in java  calculate area of circle, square,rectangele in menu driven programme in java
menu drive programm in java
menu drive programm in java  calculate area of circle, square,rectangele in menu driven programme in java
looping programm of sum
looping programm of sum  s=1+2/12+1+2+3/12*3+1+2+3+..... n
top 20 basic programm of java
top 20 basic programm of java  what is the top 20 rule to learn the basic of java.   Learn Java through the following links: http://www.roseindia.net/java/ http://www.roseindia.net/java/beginners/index.shtml
error at the oracle programm with jsp - JSP-Servlet
error at the oracle programm with jsp  an error occured at myodbc:jdbc:missig comma
how to write a programm in C for included code below
how to write a programm in C for included code below  Here is my question 'how to write a program in C that runs your sql-xml application session. In the session, you can run SQL queries interactively. The query results
could not find the main class programm will exit - error
could not find the main class programm will exit - error  when i tried to run the below mentioned programmed it gives a error states - could not find main class programm will exit. class Car { String name: String Color
is this programm efficient to find the day of the given date . can it be more normalized ?
is this programm efficient to find the day of the given date . can it be more normalized ?  #include <stdio.h> int main(void) { int dd,mm,yy,i,leap=0,ordi=0,odd_years,month_days= 0,total ; char week[7][10
A programm for error free transmission of data using UDP in java
A programm for error free transmission of data using UDP in java  Hi ! My name is Waleed and Im studing Telecommunication engineering in Oslo engineering college. I've got a project in java programming that should be submitted
menu driven
menu driven   menu driven programm in decimal to binary binary to decimal
buble sort
buble sort  ascending order by using Bubble sort programm   Java BubbleSort Example
Binary Search - Java Beginners
Binary Search  how to use Binary think in java give me the Binary Search programm thx
awt jdbc
awt jdbc  programm in java to accept the details of doctor (dno,dname,salary)user & insert it into the database(use prerparedstatement class&awt
database connectivity problem
database connectivity problem  what if client dont have database with them then what is other way to run successfully our programm   Please visit the following link: http://www.roseindia.net/jdbc
Hibernate code
Hibernate code  programm 4 hibernate  Hi, Read hibernate tutorial at http://www.roseindia.net/hibernate/ Thanks   please read at the the link http://www.roseindia.net/hibernate
que - Struts
que  how can i run a simple strut programm? please explain with a proper example. reply soon.  Hi Friend, Please visit the following link: http://www.roseindia.net/struts/ Thanks
java - Java Beginners
java  i have to make a programm in java to multiply any number with 100 without using any math operator.  To multiply with 100 no need of mathematical operators. int result=Integer.parseInt(String.valueOf(num)+"00
What is reflection? - Java Beginners
activity at runtime or examine the exceutting java programm. ex= through bello programm you can get all the list of method of MyClass same like this you can get
IJVM
to explain your programm output
IJVM
to explain your programm output
how to color the Eclipse editor background programmatically?
how to color the Eclipse editor background programmatically?  I have to color specific portion(background) of the of the Eclipse editor by running the java programm and provided that do the coloring from a given line number
java - Java Beginners
, Structure of Java programm [package declarations] [import statements] [class
Extending thread - Java Beginners
Extending thread  what is a thread & give me the programm of exeucte the thread   Hi friend, Thread : A thread is a lightweight process which exist within a program and executed to perform a special task
JSF Search - Java Server Faces Questions
JSF Search  Hi, Do you have any examples of how to do a Search programm using JSF in RAD.My Search button should carry the value of the input text field as a parameter and should search in the database for the parameter
java - Java Beginners
java  i have to make a programm in java to multiply any number with 100 without using any math operator.I hav got this answer. but i hav to make it without using +,*,/,- etc. here + is used in this. Answers To multiply
how can you calculate you your age in daies??
how can you calculate you your age in daies??  **hi, I am beginner in java! can any one help me to write programm to calculate age in daies???**   Hi Friend, Try the following code: import java.util.*; public
Send me Binary Search - Java Beginners
Send me Binary Search  how to use Binary think in java give me the Binary Search programm thx..  Hi friend, import java.io.*; public class BinarySearchDemo { public static final int NOT_FOUND = -1
 

 

 

DMCA.com