2
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3
* Copyright (C) 2006 - INRIA - Allan CORNET
4
* Copyright (C) 2007 - INRIA - Sylvestre LEDRU
6
* This file must be used under the terms of the CeCILL.
7
* This source file is licensed as described in the file COPYING, which
8
* you should have received as part of this distribution. The terms
9
* are also available at
10
* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
17
* Scilab Array of Complex Object
18
* See SCI/modules/javasci/examples/others for some simple examples
19
* @author Allan CORNET - INRIA 2006
20
* @author Sylvestre LEDRU - INRIA 2007
22
public class SciComplexArray extends javasci.SciAbstractArray implements java.io.Serializable
24
/********************************************************************************************************/
25
private double [] x; /* Real part */
26
private double [] y; /* Imaginary part */
29
* Constructs a Scilab Complex Array from a other SciComplexArray
31
* @param name the name of the Scilab variable
32
* @param complexArray the SciComplexArray Array you want to copy
35
public SciComplexArray(String name, SciComplexArray complexArray) {
37
this.m = complexArray.getNumberOfRows();
38
this.n = complexArray.getNumberOfCols();
40
this.x = new double[m * n];
41
this.x = complexArray.getRealPartData();
43
this.y = new double[m * n];
44
this.y = complexArray.getImaginaryPartData();
50
* Constructs a ScilabComplexArray
51
* All cells are initialized to 0
53
* @param name the name of the Scilab Variable
54
* @param row number of rows
55
* @param col number of columns
57
public SciComplexArray(String name, int row, int col) {
60
this.x = new double[row * col];
61
this.y = new double[row * col];
64
if ((Scilab.TypeVar(name) == 1) & // real or complex constant matrix.
65
(getNumberOfRowsFromScilab(name) == row) & // has the same number of rows
66
(getNumberOfColsFromScilab(name) == col)) // has the same number of columns
68
// load it from Scilab
72
for (int i = 0; i < row * col; i++) {
81
* Constructs a Scilab Boolean Complex from two java double array
83
* @param name the name of the Scilab Variable
84
* @param r number of rows
85
* @param c number of columns
86
* @param x the array of double with want to copy into the Real Part
87
* @param y the array of double with want to copy into the Imaginary Part
89
public SciComplexArray(String name, int r, int c, double [] x, double [] y) {
90
if ((r * c != x.length) && (r * c != y.length)) {
91
throw new BadDataArgumentException("Bad Matrix call, size of third argument is wrong");
106
* Should not be called (this method is only here for polymorphism reason)
109
* @see #getRealPartData()
110
* @see #getImaginaryPartData()
111
* @throws NoSuchMethodException if this method is called (meaning less in the case of complex)
113
public double[] getData() throws NoSuchMethodException {
114
throw new NoSuchMethodException("Cannot call getData on a Complex Data. See getRealPartData() / getImaginaryPartData() .");
118
* Return the Real part of the data
120
* @return the real part of the data
122
public String getName() {
127
* returns the real data of the complex array
129
* @return the real data
131
public double[] getRealPartData() {
137
* Get only ONE element from Scilab Matrix
140
* @param indr row indice in scilab
141
* @param indc column indice in scilab
142
* @return the Real Part
144
public native double GetRealPartElement(int indr, int indc);
147
* Get only ONE element from Scilab Matrix
150
* @param indr row indice in scilab
151
* @param indc column indice in scilab
152
* @return the Imaginary Part
155
public native double GetImaginaryPartElement(int indr, int indc);
158
* Return the Imaginary part of the data
160
* @return the Imaginary part of the data
162
public double[] getImaginaryPartData() {
167
/********************************************************************************************************/