~ubuntu-branches/ubuntu/trusty/scilab/trusty

« back to all changes in this revision

Viewing changes to modules/javasci/src/java/javasci/SciComplexArray.java

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-08-02 11:02:49 UTC
  • mfrom: (1.4.6)
  • Revision ID: package-import@ubuntu.com-20120802110249-0v5953emkp25geuz
Tags: 5.4.0-beta-2-1~exp1
* New upstream release
* Remove libscilab-java (remove upstream). Use libscilab2-java instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
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
5
 
 * 
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
11
 
 *
12
 
 */
13
 
 
14
 
package javasci;
15
 
 
16
 
/**
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
21
 
 */
22
 
public class SciComplexArray extends javasci.SciAbstractArray implements java.io.Serializable
23
 
{
24
 
/********************************************************************************************************/
25
 
 private double [] x; /* Real part */
26
 
 private double [] y; /* Imaginary part */
27
 
 
28
 
        /**
29
 
         * Constructs a Scilab Complex Array from a other SciComplexArray
30
 
     * @deprecated
31
 
         * @param name the name of the Scilab variable
32
 
         * @param complexArray the SciComplexArray Array you want to copy
33
 
         */
34
 
 
35
 
  public SciComplexArray(String name, SciComplexArray complexArray) {
36
 
    this.name = name;
37
 
    this.m = complexArray.getNumberOfRows();
38
 
    this.n = complexArray.getNumberOfCols();
39
 
 
40
 
        this.x = new double[m * n];
41
 
        this.x = complexArray.getRealPartData();
42
 
    
43
 
        this.y = new double[m * n];
44
 
        this.y = complexArray.getImaginaryPartData();
45
 
    
46
 
        Send();
47
 
 }
48
 
 
49
 
        /**
50
 
         * Constructs a ScilabComplexArray
51
 
         * All cells are initialized to 0
52
 
     * @deprecated
53
 
         * @param name  the name of the Scilab Variable
54
 
         * @param row number of rows
55
 
         * @param col number of columns
56
 
         */
57
 
  public SciComplexArray(String name, int row, int col) {
58
 
    this.m = row;
59
 
    this.n = col;
60
 
    this.x = new double[row * col];
61
 
    this.y = new double[row * col];
62
 
    this.name = name;
63
 
    
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
67
 
    {
68
 
                // load it from Scilab
69
 
                Get();
70
 
 
71
 
    } else {
72
 
        for (int i = 0; i < row * col; i++) {
73
 
          x[i] = 0;
74
 
          y[i] = 0;
75
 
        }
76
 
                // send it to scilab
77
 
        Send();
78
 
    }
79
 
  }
80
 
        /**
81
 
         * Constructs a Scilab Boolean Complex  from two java double array
82
 
     * @deprecated
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
88
 
         */
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");
92
 
    }
93
 
 
94
 
        this.m = r;
95
 
        this.n = c;
96
 
    
97
 
        this.x = x;
98
 
        this.y = y;
99
 
    
100
 
        this.name = name;
101
 
    
102
 
        Send();
103
 
 }
104
 
 
105
 
        /**
106
 
         * Should not be called (this method is only here for polymorphism reason)
107
 
         * @return the array
108
 
         * @deprecated
109
 
         * @see #getRealPartData()
110
 
         * @see #getImaginaryPartData()
111
 
         * @throws NoSuchMethodException if this method is called (meaning less in the case of complex)
112
 
         */
113
 
        public double[] getData() throws NoSuchMethodException {
114
 
                throw new NoSuchMethodException("Cannot call getData on a Complex Data. See getRealPartData() / getImaginaryPartData() .");
115
 
        }
116
 
 
117
 
        /**
118
 
         * Return the Real part of the data
119
 
     * @deprecated
120
 
         * @return the real part of the data 
121
 
         */
122
 
 public String getName() {
123
 
        return name;
124
 
 }
125
 
 
126
 
 /**
127
 
  * returns the real data of the complex array
128
 
  * @deprecated
129
 
  * @return the real data
130
 
  */
131
 
public double[] getRealPartData() {
132
 
        Get();
133
 
        return x;
134
 
 }
135
 
        
136
 
/**
137
 
 * Get only ONE element from Scilab Matrix 
138
 
 * Get Real Part
139
 
 * @deprecated
140
 
 * @param indr row indice in scilab
141
 
 * @param indc column indice in scilab 
142
 
 * @return the Real Part
143
 
 */
144
 
 public native double GetRealPartElement(int indr, int indc);
145
 
 
146
 
 /**
147
 
 * Get only ONE element from Scilab Matrix 
148
 
 * Get Real Part
149
 
 * @deprecated
150
 
 * @param indr row indice in scilab
151
 
 * @param indc column indice in scilab 
152
 
 * @return the Imaginary Part 
153
 
 */
154
 
 
155
 
 public native double GetImaginaryPartElement(int indr, int indc);
156
 
 
157
 
        /**
158
 
         * Return the Imaginary part of the data
159
 
     * @deprecated
160
 
         * @return the Imaginary part of the data 
161
 
         */
162
 
 public double[] getImaginaryPartData() {
163
 
        Get();
164
 
        return y;
165
 
 }
166
 
}
167
 
/********************************************************************************************************/