apurva kale
programm
1 Answer(s)      2 years and 3 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|

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 Pages:
write a programm using java
write a programm using java  print the following using java programming
looping programm of sum
looping programm of sum  s=1+2/12+1+2+3/12*3+1+2+3+..... n
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
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
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
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
Binary Search - Java Beginners
Binary Search  how to use Binary think in java give me the Binary Search programm thx
buble sort
buble sort  ascending order by using Bubble sort programm   Java BubbleSort Example
menu driven
menu driven   menu driven programm in decimal to binary binary to decimal
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
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
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
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
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
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
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
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
java - Java Beginners
, Structure of Java programm [package declarations] [import statements] [class
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
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
Arrays
Arrays  Create a program to mark and grade a set of multiple choice test results.This is a console programm that uses JOptionPane dialog boxes... the confirmation box displaying The information has been saved. The programm
file
file  hi i want read special line of file. what am i doing ? I write a code but is false in this programm i want make tree with java but i should read data from file. please help me! void maketree(BtNode root,int i) throws
help me
help me  Dear sir/medam i would like to know how to use the java string class method my programm have four button,(enter the text) that first button is To upper case,second button is lower case Third button is Reverse
compilation error - Java Beginners
: C:\>javac -d . Group.java 3)For execute the programm : C:\>java
AUSTRUMI 1.1.0 has been released now
support. The Programm 1. Graphic gimageview - image browser gimp - Image
C and C++ books-page11
++ Programm Object-oriented (OO) programming languages treat user-defined types
java program - Java Beginners
java program  plzzzzz help me on this java programming question? hello people.. can u plzzzzzzzzzzzzzzzzzzz help me out with this java programm. its due tmrw....... and i havent even get started on this program. i dont want
Need help in java programming
Need help in java programming  Hello. Can someone please help me with writig the following programm. Assignment 20% Presentation 10% Mini Test 10% Exam 60% Java program that accepts the following details: student
Why this is not working...?
Object { String colour }   This is the output after i run the programm

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.