IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

avec Java Discussion :

multiplication parallele des matrices


Sujet :

avec Java

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2013
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Avril 2013
    Messages : 16
    Points : 7
    Points
    7
    Par défaut multiplication parallele des matrices
    Bonjour.

    je suis débutant dans le Java et je besoin d'une aide pour la multiplication parallèle des matrices.

  2. #2
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Citation Envoyé par zerhem Voir le message
    Bonjour.

    je suis débutant dans le Java et je besoin d'une aide pour la multiplication parallèle des matrices.
    Bonjour,

    Où bloques tu? peut on voir ce que tu as déjà essayé de produire?
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

  3. #3
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2013
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Avril 2013
    Messages : 16
    Points : 7
    Points
    7
    Par défaut
    Bonjour.
    j'arrive écrire des programmes parallèle , mais quand je veux le faire pour les matrices, je ne savais pas comment décomposer le traitement de calcule

  4. #4
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Citation Envoyé par zerhem Voir le message
    Bonjour.
    j'arrive écrire des programmes parallèle , mais quand je veux le faire pour les matrices, je ne savais pas comment décomposer le traitement de calcule
    Qu'entends tu par programme parallèle?
    Citation Envoyé par zerhem Voir le message
    mais quand je veux le faire pour les matrices, je ne savais pas comment décomposer le traitement de calcule
    Sais tu traiter une matrice en algorithme pur ? Sans aucun langage je veux dire.
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

  5. #5
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2013
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Avril 2013
    Messages : 16
    Points : 7
    Points
    7
    Par défaut
    Merci.

    voici un code de multiplication de deux matrice :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    import java.util.*;
    import java.util.Random;
     
    class MatrixMultiplication{
     
    public static void main(String[] args){
    Scanner input = new Scanner(System.in);
    System.out.print("Entrez le nombre de rangées : ");
    int m = input.nextInt();
    Random r = new Random();
    System.out.print("Entrez le nombre de colonnes : ");
    int n = input.nextInt();
     
    int[][] A = new int[m][n];
    int[][] B = new int[m][n];
    int[][] C = new int[m][n];
     
     
     
    for (int i=0 ; i < A.length ; i++)
    for (int j=0 ; j < A[i].length ; j++){
    A[i][j] = r.nextInt(100) + 0;
    }
     
     
     
    for (int i=0 ; i < B.length ; i++)
    for (int j=0 ; j < B[i].length ; j++){
    B[i][j] = r.nextInt(100) + 0;
    }
     
     
     
    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("Matrice 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("Le résultat est : ");
    System.out.println();
     
    for(int i=0;i<A.length;i++){
    for(int j=0;j<B[0].length;j++){
    for(int k=0;k<A[0].length;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();
    } 
    }
    }


    mais j'arrive pas de l’écrire en parallèle " multi thread ", pour être exécuté par plusieurs thread

  6. #6
    Modérateur
    Avatar de wax78
    Homme Profil pro
    Chef programmeur
    Inscrit en
    Août 2006
    Messages
    4 073
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chef programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 4 073
    Points : 7 978
    Points
    7 978
    Par défaut
    Par exemple, avant tu avais :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    for(int i=0;i<A.length;i++);
    Et pour décomposer naïvement en 2 "tâches", tu pourrais avoir :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    for(int i=0;i<A.length/2;i++);
    for(int i=A.length/2;i<A.length;i++);
    (Les "ça ne marche pas", même écrits sans faute(s), vous porteront discrédit ad vitam æternam et malheur pendant 7 ans)

    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  7. #7
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2013
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Avril 2013
    Messages : 16
    Points : 7
    Points
    7
    Par défaut
    Merci pour ton aide.
    mais j'arrive de le faire fonctionné

    voici le mon code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package par;
     
    import java.util.Random;
    import java.util.Scanner;
     
    /**
     *
     * @author zerhem
     */
     
     
     
    class MyThread extends Thread {
        private int debut, fin; 
        private int[][] Aa = new int[100][100];
        private int[][] Bb = new int[100][100];
        MyThread(int d, int m, int[][] A, int[][] B){
            this.debut = d;
            this.fin = m;
            this.Aa = A;
            this.Bb = B;
     
             this.start();
     
        }
     
     
    public void run (){
    for( int i = this.debut;i<this.fin;i++){
    for(int j=0;j<Bb.length;j++){
    for(int k=0;k<Aa.length;k++){
    Par.C[i][j]+=Aa[i][k]*Bb[k][j];
    }
    }
    }
     
    }
    }
    public class Par {
    public static int[][] C = new int[100][100];
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            // TODO code application logic here
     
            Scanner input = new Scanner(System.in);
    System.out.print("Entrez le nombre de rangées : ");
    int m = input.nextInt();
    Random r = new Random();
    System.out.print("Entrez le nombre de colonnes : ");
    int n = input.nextInt();
     
    int[][] A = new int[m][n];
    int[][] B = new int[m][n];
    //int[][] C = new int[m][n];
     
     
     
    for (int i=0 ; i < A.length ; i++)
    for (int j=0 ; j < A[i].length ; j++){
    A[i][j] = r.nextInt(10) + 1;
    }
     
     
     
    for (int i=0 ; i < B.length ; i++)
    for (int j=0 ; j < B[i].length ; j++){
    B[i][j] = r.nextInt(10) + 1;
    }
     
     
    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("Matrice 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();
    System.out.println();
    System.out.println("Le résultat est : ");
    System.out.println();
     
     
     
     
    int d = 0;
            MyThread myThread = new MyThread(d,A.length/2, A, B);
     
     
            Thread myThread1 = new MyThread(A.length/2,A.length, A, B);
     
     
     
     
     
    for(int i=0;i<A.length;i++){
    for(int j=0;j<B.length;j++){
    System.out.print(+C[i][j]+" ");
    }
    System.out.println();
    } 
     
     
     
        }
    }

  8. #8
    Modérateur
    Avatar de wax78
    Homme Profil pro
    Chef programmeur
    Inscrit en
    Août 2006
    Messages
    4 073
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chef programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 4 073
    Points : 7 978
    Points
    7 978
    Par défaut
    Ha bon, quelle erreur as-tu ? Moi j'ai lancé le code et il est passé, par contre tu n'as pas attendu la fin des Thread avant d'affiche le résultat
    (Les "ça ne marche pas", même écrits sans faute(s), vous porteront discrédit ad vitam æternam et malheur pendant 7 ans)

    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  9. #9
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2013
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Avril 2013
    Messages : 16
    Points : 7
    Points
    7
    Par défaut
    il donne des mauvaise résultats , je pense que il manque la synchronisation .
    pour que la matrice C affiche correctement.et je ne savais pas comment le faire

  10. #10
    Modérateur
    Avatar de wax78
    Homme Profil pro
    Chef programmeur
    Inscrit en
    Août 2006
    Messages
    4 073
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chef programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 4 073
    Points : 7 978
    Points
    7 978
    Par défaut
    Oui voila je venais de le rajouter dans mon post, il manque un ou des join quelques part
    (Les "ça ne marche pas", même écrits sans faute(s), vous porteront discrédit ad vitam æternam et malheur pendant 7 ans)

    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  11. #11
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2013
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Avril 2013
    Messages : 16
    Points : 7
    Points
    7
    Par défaut
    merci.



    es que tu peux m'aide pour ce probleme

  12. #12
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2013
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Avril 2013
    Messages : 16
    Points : 7
    Points
    7
    Par défaut
    Salut


    j'ai modifie le plupart de code, tu peux le vérifié es que est vraiment multi-thread
    parce que je suis pas sure que il marche bien



    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    /*
     /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package matr;
     
    import java.util.Random;
    import java.util.Scanner;
     
    /**
     *
     * @author zerhem
     */
     
    public class moi extends Thread {
        private int[][] AA, BB;
       public int [][]  CC; // 
      private int debut, fin; // 
      private Trieur parent;  // 
        private int nbNotify = 0; // 
     
        public moi (int[][] A, int[][] B, int[][] C) {
        this(null, A, B, C, 0, A.length , B.length );
     
            System.out.println("kjdqgvqkvq  fin MOI(A,B) : " );
            System.out.println("A.length =  "+A.length );
            System.out.println("AA.length =  "+AA.length );
     
     
            System.out.println("B.length =  "+B.length );
            System.out.println("BB.length =  "+BB.length );
      }
     
     
        public moi (Trieur parent, int[][] A, int[][] B, int[][] C, int debut, int fin, int BB) {
            System.out.println("Trieur parent, int[][] A, int[][] B, int debut, int fin, int BB : " );
        this.parent = parent;
        this.AA = A;
        this.BB = B;
        this.CC = C;
        this.debut = debut;
        this.fin = fin;
        start();
      }
     
     
        public synchronized void notifier() {
        // Notifie tous les thread en attente sur "ce" (this) moniteur
        // Attention, quand le message sera envoyé au parent (dans run()),
        // on incrémentera la variable nbNotify du parent (qui sera le this
        // implicite) et on notifiera le parent.
        // On peut aussi ne pas utiliser de méthode mais dans ce cas, il faut
        // écrire parent.nbNotify++; parent.notifyAll(); dans un bloc 
        // synchronisé sur parent placé dans la méthode run.
        this.nbNotify++;
        this.notifyAll();
     
        }
        public void run() {
            System.out.println("run : " );
            for( int i = this.debut;i<this.fin;i++){
                System.out.println("for 1 : " );
                for(int j=0;j<BB.length;j++){
                    System.out.println("for 2 : " );
                    for(int k=0;k<AA.length;k++){
     
                        CC[i][j]+=AA[i][k]*BB[k][j];
                        System.out.println("for 3 : " );
     
                    }
     
                }
     
            }
     
     
     
     
            if (parent != null) {
          parent.notifier(); // indique qu'il a fini au parent qui l'attend
        }
     
        }
     
     
     public static void main(String[] args)  {
        int m, n;
     
             Scanner input = new Scanner(System.in);
    System.out.print("Entrez le nombre de rangées : ");
     m = input.nextInt();
    Random r = new Random();
    System.out.print("Entrez le nombre de colonnes : ");
     n = input.nextInt();
     
     
    int[][] A = new int[m][n];
    int[][] B = new int[m][n];
    int[][] C = new int[m][n];
     
     
    for (int i=0 ; i < A.length ; i++)
    for (int j=0 ; j < A[i].length ; j++){
    A[i][j] = r.nextInt(10) + 1;
    }
     
     
     
    for (int i=0 ; i < B.length ; i++)
    for (int j=0 ; j < B[i].length ; j++){
    B[i][j] = r.nextInt(10) + 1;
    }
     
     
    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("Matrice 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();
     
     
     
     
    moi mo = new moi(A, B, C);
        try {
          mo.join();
        }
        catch(InterruptedException e) {}
        for(int i=0;i<A.length;i++){
    for(int j=0;j<B.length;j++){
    System.out.print(+C[i][j]+" ");
    }
    System.out.println();
    }
        System.out.println();
     
     
     
     
     
     
        }
     
     
     
     
     
     
     
     
     
     
    }

  13. #13
    Modérateur
    Avatar de wax78
    Homme Profil pro
    Chef programmeur
    Inscrit en
    Août 2006
    Messages
    4 073
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chef programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 4 073
    Points : 7 978
    Points
    7 978
    Par défaut
    Combien d'instance de la classe "moi" (donc de threads potentiel) crées tu ?

    A priori 1, donc non ce n'est pas multithread.

    La solution du dessus était, pour moi, la bonne si ce n'est qu'il manquait 2 join avant l'affichage des résultats afin d'attendre la fin du calcul de chacun des bouts de la matrice. (pas besoin d'autres synchronisation dans ce cas ci en plus).


    Edit : Faut pas jouer avec des parent et de méthode notifier, je n'avais pas fait gaffe a cela au début, mais je pense pas que cela soit la bonne solution car quoiqu'il arrive même si ton architecture serait potentiellement bonne, chaque thread enfant attendrait la fin de son père si j'ai bien compris et donc ca ne serait pas exécuté en //
    (Les "ça ne marche pas", même écrits sans faute(s), vous porteront discrédit ad vitam æternam et malheur pendant 7 ans)

    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  14. #14
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Avril 2013
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Avril 2013
    Messages : 16
    Points : 7
    Points
    7
    Par défaut
    Merci pour ton aide.

    j'ai corrigée le code par l’enlèvement l’implémentation des parent

    c'est un code fonctionnel , je met ici pour les débutants comme moi

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package matr;
     
    import java.util.Random;
    import java.util.Scanner;
     
    /**
     *
     * @author zerhem
     */
    public class moi extends Thread {
     
        private int[][] AA, BB;
        public int[][] CC; // 
        private int debut, fin; // 
        private Trieur parent;  // 
        private int nbNotify = 0; // 
     
        public moi(int[][] A, int[][] B, int[][] C, int d, int f) {
            this.AA = A;
            this.BB = B;
            this.CC = C;
            this.debut = d;
            this.fin = f;
            System.out.println("kjdqgvqkvq  fin MOI(A,B) : ");
            System.out.println("A.length =  " + A.length);
            System.out.println("AA.length =  " + AA.length);
     
     
            System.out.println("B.length =  " + B.length);
            System.out.println("BB.length =  " + BB.length);
     
     
            start();
        }
     
        public void run() {
            System.out.println("run : ");
            for (int i = this.debut; i < this.fin; i++) {
                System.out.println("for 1 : ");
                for (int j = 0; j < BB.length; j++) {
                    System.out.println("for 2 : ");
                    for (int k = 0; k < AA.length; k++) {
     
                        CC[i][j] += AA[i][k] * BB[k][j];
                        System.out.println("for 3 : ");
     
                    }
     
                }
     
            }
     
        }
     
        public static void main(String[] args) {
            int m, n, d, f;
     
            Scanner input = new Scanner(System.in);
            System.out.print("Entrez le nombre de rangées : ");
            m = input.nextInt();
            Random r = new Random();
            System.out.print("Entrez le nombre de colonnes : ");
            n = input.nextInt();
     
     
            int[][] A = new int[m][n];
            int[][] B = new int[m][n];
            int[][] C = new int[m][n];
            int[][] Cs = new int[m][n];
     
            for (int i = 0; i < A.length; i++) {
                for (int j = 0; j < A[i].length; j++) {
                    A[i][j] = r.nextInt(10) + 1;
                }
            }
            for (int i = 0; i < B.length; i++) {
                for (int j = 0; j < B[i].length; j++) {
                    B[i][j] = r.nextInt(10) + 1;
                }
            }
            System.out.println("Matrice 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("Matrice 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();
     
     
     
            d = 0;
            f = A.length / 2;
            moi mo = new moi(A, B, C, d, f);
            d = A.length / 2;
            f = A.length;
            moi mo1 = new moi(A, B, C, d, f);
     
            try {
                mo.join();
                mo1.join();
            } catch (InterruptedException e) {
            }
     
     
            System.out.println("Le résultat est: ");
            for (int i = 0; i < A.length; i++) {
                for (int j = 0; j < B.length; j++) {
                    System.out.print(+C[i][j] + " ");
                }
                System.out.println();
            }
        }
    }

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Multiplication des matrices
    Par nadine01 dans le forum Général Java
    Réponses: 3
    Dernier message: 30/12/2014, 10h17
  2. [Débutant] la multiplication des matrices
    Par brf1982 dans le forum MATLAB
    Réponses: 6
    Dernier message: 20/10/2012, 18h35
  3. Ordre dans la multiplication des matrices
    Par Balmung dans le forum OpenGL
    Réponses: 4
    Dernier message: 06/07/2009, 17h51
  4. [debutant]Utiliser des matrices en C
    Par Battosaiii dans le forum C
    Réponses: 2
    Dernier message: 13/11/2005, 20h45
  5. Réponses: 6
    Dernier message: 13/09/2003, 12h42

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo