SciBooleanArray.java

Go to the documentation of this file.
00001 /*
00002  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
00003  * Copyright (C) 2007 - INRIA - Allan CORNET
00004  * Copyright (C) 2007 - INRIA - Sylvestre LEDRU
00005  * 
00006  * This file must be used under the terms of the CeCILL.
00007  * This source file is licensed as described in the file COPYING, which
00008  * you should have received as part of this distribution.  The terms
00009  * are also available at    
00010  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
00011  *
00012  */
00013 
00014 package javasci;
00015 
00022 public class SciBooleanArray extends javasci.SciAbstractArray implements java.io.Serializable {
00023 
00024  private boolean [] x;
00025 
00031   public SciBooleanArray(String name, SciBooleanArray booleanArray) {
00032     this.name = name;
00033     this.m = booleanArray.getNumberOfRows();
00034     this.n = booleanArray.getNumberOfCols();
00035     this.x = new boolean[m * n];
00036 
00037     this.x = booleanArray.getData();
00038     Send();
00039   }
00040 
00048   public SciBooleanArray(String name, int r, int c) {
00049     this.m = r;
00050     this.n = c;
00051     this.x = new boolean[r * c];
00052     this.name = name;
00053     
00054     if ((Scilab.TypeVar(name) == 4) // boolean matrix
00055          & (getNumberOfRowsFromScilab(name) == r) // has the same number of rows
00056          & (getNumberOfColsFromScilab(name) == c)) // has the same number of columns
00057     {
00058                 // load it from Scilab
00059                 Get();
00060     } else {
00061                 // Create it
00062         for (int i = 0; i < (r * c); i++) { 
00063                         x[i] = false;
00064         }
00065                 // send it to scilab
00066         Send(); 
00067     }
00068   }
00069 
00077   public SciBooleanArray(String name, int r, int c, boolean[] x) {
00078     if ((r * c) != x.length) {
00079      throw new BadDataArgumentException("Bad Matrix call, size of third argument is wrong");
00080     }
00081     this.m = r;
00082     this.n = c;
00083     this.x = x;
00084     this.name = name;
00085     Send();
00086   }
00087   
00088 
00099   public native boolean GetElement(int indr, int indc);
00100 
00101 
00106   public boolean[] getData() {
00107           Get(); // connection to the Scilab Engine
00108    return x;
00109   }
00110 }
00111 

Generated on Tue Sep 9 17:48:27 2008 for Scilab [trunk] by  doxygen 1.5.5