programm

programm

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 Tutorials/Questions & Answers:
programm
programm
Advertisements
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
java programm
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
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
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
construction in java programm
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
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
IJVM
to explain your programm output
IJVM
to explain your programm output
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,ADS_TO_REPLACE_1 Try the following code: import
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
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
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
compilation error - Java Beginners
: C:\>javac -d . Group.java 3)For execute the programm : C:\>java
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... **** 4. Enter your move: q n *** Invalid source. Please retry **** 4. Enter
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

Ads