org.scilab.modules.types
Class ScilabDouble

java.lang.Object
  extended by org.scilab.modules.types.ScilabDouble
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, ScilabType
Direct Known Subclasses:
ScilabDoubleReference

public class ScilabDouble
extends java.lang.Object
implements ScilabType

This class provides a representation on the Scilab Double datatype
Note that double is the default datatype in Scilab.

This class is Serializable and any modification could impact load and store of data (Xcos files, Javasci saved data, etc...).

Example (real):
double [][]a={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
ScilabDouble aMatrix = new ScilabDouble(a);

Example (complex):
double [][]a={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
double [][]aImg={{210.2, 220.0, 420.0, 390.0},{230.2, 240.0, 440.0, 400.0}};
ScilabDouble aMatrix = new ScilabDouble(a, aImg);

See Also:
Scilab, Serialized Form

Field Summary
protected  boolean byref
           
protected  double[][] imaginaryPart
           
protected  double[][] realPart
           
protected  boolean swaped
           
protected  java.lang.String varName
           
 
Constructor Summary
ScilabDouble()
          Default constructor
ScilabDouble(double data)
          Constructor with a unique value.
ScilabDouble(double[][] data)
          Constructor with a matrix of real data.
ScilabDouble(double[][] realData, double[][] imagData)
          Constructor with a matrix of complex numbers
ScilabDouble(double realData, double imagData)
          Constructor with a unique complex value.
ScilabDouble(java.lang.String varName, double[][] realData, double[][] imagData, boolean swaped)
          Constructor with a matrix of complex numbers
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compare if obj is the same object or not
 double[] getElement(int i, int j)
          Get the complex at position (i, j) as a 2-length row-vector
 int getHeight()
          Return the height (number of elements) of the stored data
 double getImaginaryElement(int i, int j)
          Get the element at position (i, j) in the imaginary part
 double[][] getImaginaryPart()
          Get the imaginary part of the data.
 java.lang.Object getRawImaginaryPart()
          Get the raw data
 java.lang.Object getRawRealPart()
          Get the raw data
 double getRealElement(int i, int j)
          Get the element at position (i, j) in the real part
 double[][] getRealPart()
          Get the real part of the data.
 double[] getSerializedComplexMatrix()
          Get complex matrix as a serialized form
 java.lang.Object getSerializedObject()
          Get a single object used to easily rebuild a Scilab variable from the Java ScilabType
 ScilabTypeEnum getType()
          Return the type of Scilab
 java.lang.String getVarName()
          Get the variable name or null if it has not a name
 int getWidth()
          Return the width (number of elements) of the stored data
 boolean isEmpty()
          Check the emptiness of the associated data.
 boolean isReal()
          Check if the current data doesn't have an imaginary part.
 boolean isReference()
          
 boolean isSwaped()
          Get the how the matrix is stored
 void readExternal(java.io.ObjectInput in)
           
 void setElement(int i, int j, double x, double y)
          Set the element at position (i, j)
 void setImaginaryElement(int i, int j, double x)
          Set the element at position (i, j) in the imaginary part
 void setImaginaryPart(double[][] imaginaryPart)
          Set the imaginary part of the data.
 void setRealElement(int i, int j, double x)
          Set the element at position (i, j) in the real part
 void setRealPart(double[][] realPart)
          Set the real part of the data.
 java.lang.String toString()
          Display the representation in the Scilab language of the type
Note that the representation can be copied/pasted straight into Scilab
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

realPart

protected double[][] realPart

imaginaryPart

protected double[][] imaginaryPart

varName

protected java.lang.String varName

swaped

protected boolean swaped

byref

protected transient boolean byref
Constructor Detail

ScilabDouble

public ScilabDouble()
Default constructor


ScilabDouble

public ScilabDouble(double data)
Constructor with a unique value.

Parameters:
data - the unique value

ScilabDouble

public ScilabDouble(double realData,
                    double imagData)
Constructor with a unique complex value.

Parameters:
realData - the real part
imagData - the complex part

ScilabDouble

public ScilabDouble(double[][] data)
Constructor with a matrix of real data.

Parameters:
data - the data

ScilabDouble

public ScilabDouble(double[][] realData,
                    double[][] imagData)
Constructor with a matrix of complex numbers

Parameters:
realData - the real part of the data
imagData - the imaginary part of the data

ScilabDouble

public ScilabDouble(java.lang.String varName,
                    double[][] realData,
                    double[][] imagData,
                    boolean swaped)
Constructor with a matrix of complex numbers

Parameters:
realData - the real part of the data
imagData - the imaginary part of the data
Method Detail

getType

public ScilabTypeEnum getType()
Return the type of Scilab

Specified by:
getType in interface ScilabType
Returns:
the type of Scilab
Since:
5.4.0

isEmpty

public boolean isEmpty()
Check the emptiness of the associated data.

Specified by:
isEmpty in interface ScilabType
Returns:
true, if the associated data array is empty.

isReference

public boolean isReference()

Specified by:
isReference in interface ScilabType
Returns:
true if data are backed in a java.nio.Buffer

isReal

public boolean isReal()
Check if the current data doesn't have an imaginary part.

Returns:
true, if the data are real only.

getRealPart

public double[][] getRealPart()
Get the real part of the data.

Returns:
the real part.

setRealPart

public void setRealPart(double[][] realPart)
Set the real part of the data.

Parameters:
realPart - the real part.

getImaginaryPart

public double[][] getImaginaryPart()
Get the imaginary part of the data.

Returns:
the imaginary part.

setImaginaryPart

public void setImaginaryPart(double[][] imaginaryPart)
Set the imaginary part of the data.

Parameters:
imaginaryPart - the imaginary part.

getVarName

public java.lang.String getVarName()
Get the variable name or null if it has not a name

Specified by:
getVarName in interface ScilabType
Returns:
the name

isSwaped

public boolean isSwaped()
Get the how the matrix is stored

Specified by:
isSwaped in interface ScilabType
Returns:
true if the matrix is stored row by row

getRealElement

public double getRealElement(int i,
                             int j)
Get the element at position (i, j) in the real part

Parameters:
i - the first coordinate
j - the second coordinate
Returns:
the corresponding double

getImaginaryElement

public double getImaginaryElement(int i,
                                  int j)
Get the element at position (i, j) in the imaginary part

Parameters:
i - the first coordinate
j - the second coordinate
Returns:
the corresponding double

getElement

public double[] getElement(int i,
                           int j)
Get the complex at position (i, j) as a 2-length row-vector

Parameters:
i - the first coordinate
j - the second coordinate
Returns:
the corresponding complex

setRealElement

public void setRealElement(int i,
                           int j,
                           double x)
Set the element at position (i, j) in the real part

Parameters:
i - the first coordinate
j - the second coordinate
x - the new value

setImaginaryElement

public void setImaginaryElement(int i,
                                int j,
                                double x)
Set the element at position (i, j) in the imaginary part

Parameters:
i - the first coordinate
j - the second coordinate
x - the new value

setElement

public void setElement(int i,
                       int j,
                       double x,
                       double y)
Set the element at position (i, j)

Parameters:
i - the first coordinate
j - the second coordinate
x - the new value for real part
y - the new value for imaginary part

getRawRealPart

public java.lang.Object getRawRealPart()
Get the raw data

Returns:
the real part

getRawImaginaryPart

public java.lang.Object getRawImaginaryPart()
Get the raw data

Returns:
the imaginary part

getSerializedComplexMatrix

public double[] getSerializedComplexMatrix()
Get complex matrix as a serialized form

Returns:
the serialized matrix with complex values

getSerializedObject

public java.lang.Object getSerializedObject()
Get a single object used to easily rebuild a Scilab variable from the Java ScilabType

Specified by:
getSerializedObject in interface ScilabType
Returns:
an very simple object reflecting this ScilabType.

getHeight

public int getHeight()
Description copied from interface: ScilabType
Return the height (number of elements) of the stored data

Specified by:
getHeight in interface ScilabType
Returns:
the height of the data matrix
See Also:
ScilabType.getHeight()

getWidth

public int getWidth()
Description copied from interface: ScilabType
Return the width (number of elements) of the stored data

Specified by:
getWidth in interface ScilabType
Returns:
the width of the data matrix
See Also:
ScilabType.getWidth()

equals

public boolean equals(java.lang.Object obj)
Description copied from interface: ScilabType
Compare if obj is the same object or not

Specified by:
equals in interface ScilabType
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object we want to compare
Returns:
true if the two objects are equals, false otherwise
See Also:
ScilabType.equals(Object)

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

toString

public java.lang.String toString()
Display the representation in the Scilab language of the type
Note that the representation can be copied/pasted straight into Scilab

Specified by:
toString in interface ScilabType
Overrides:
toString in class java.lang.Object
Returns:
a Scilab-like String representation of the data.
See Also:
Object.toString()