KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > examples > algebra > Test


1 /*
2  * ################################################################
3  *
4  * ProActive: The Java(TM) library for Parallel, Distributed,
5  * Concurrent computing with Security and Mobility
6  *
7  * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8  * Contact: proactive-support@inria.fr
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23  * USA
24  *
25  * Initial developer(s): The ProActive Team
26  * http://www.inria.fr/oasis/ProActive/contacts.html
27  * Contributor(s):
28  *
29  * ################################################################
30  */

31 package org.objectweb.proactive.examples.algebra;
32
33 import org.objectweb.proactive.core.config.ProActiveConfiguration;
34
35
36 public class Test extends Object JavaDoc {
37     public static void main(String JavaDoc[] args) {
38         int n = 1000;
39         int m = n / 2;
40         if (args.length == 1) {
41             m = Integer.decode(args[0]).intValue();
42         }
43         
44         ProActiveConfiguration.load();
45
46         Matrix m0;
47         Matrix m1;
48         Matrix m2;
49         Vector v0;
50         Vector v1;
51         Vector v2;
52
53         // Creates and randomly fills in both matrix and vector
54
m0 = new Matrix(n, n);
55         v0 = new Vector(n);
56
57         m0.randomizeFillIn();
58         v0.randomizeFillIn();
59
60         // Creates both submatrixs, with sizes m and n-m
61
try {
62             Object JavaDoc[] parameters1 = { m0.getBlock(0, 0, m, n - 1) };
63
64             //System.out.println("Le parametre est " + parameters1[0]);
65
m1 = (Matrix) org.objectweb.proactive.ProActive.newActive(Matrix.class.getName(),
66                     parameters1);
67             //m1 = (Matrix) org.objectweb.proactive.ProActive.newActive(Matrix.class.getName(), null,null);
68
Object JavaDoc[] parameters2 = { m0.getBlock(m + 1, 0, n - 1, n - 1) };
69             m2 = (Matrix) org.objectweb.proactive.ProActive.newActive(Matrix.class.getName(),
70                     parameters2);
71
72             // Computes both products
73
long begin = System.currentTimeMillis();
74             ;
75             v1 = m1.rightProduct(v0);
76             v2 = m2.rightProduct(v0);
77             // Creates result vector
78
v1.concat(v2);
79             long end = System.currentTimeMillis();
80             ;
81
82             System.out.println("Elapsed time = " + (end - begin) + " ms");
83         } catch (Exception JavaDoc e) {
84             System.out.println("Exception while creating matrixes:\n" + e);
85             e.printStackTrace();
86         }
87         System.exit(0);
88     }
89 }
90
Popular Tags