programm

Ads
 

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();
} 
}
}

Ads









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
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
java programm
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
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
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
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
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
Why this is not working...?
Object { String colour }   This is the output after i run the programm

Ads