jhplot
Class PND

java.lang.Object
  extended by jhplot.PND

public class PND
extends java.lang.Object

A container to hold data points in many dimensions. All numbers are expected to be in double precision. It extends ArrayList and adds many new features for data manipulation. The class does not have graphical option (use H1D to show the data or methods of this class which transform P0D to a H1D histogram).


Constructor Summary
PND()
          Construct an empty container with no title
PND(java.lang.String title)
          Construct an empty container with a title
PND(java.lang.String title, boolean shallow, PND pnd)
          Construct a copy from a PND.
PND(java.lang.String title, java.lang.String file)
          Construct a container with a title from external file (see the method toFile() how to write such ASCII file)
 
Method Summary
 void add(double[] values)
          Adds (appends) the specified element to the end of this list.
 void add(P0D values)
          Adds (appends) P0D to the end of this list.
 void clear()
          Clear the container
 PND copy(java.lang.String newtitle)
           
 double[] get(int row)
          Return a specific row as array
 double get(int row, int column)
          Return a specific value.
 double[][] getArray()
          Get a double array with values.
 java.util.ArrayList<double[]> getArrayList()
          Get data in form of ArrayList
 P0D getColumn(int column)
          Return a specific row as array
 int getDimension()
          Get last dimension of the data.
 P0D getRow(int row)
          Return a specific row as array
 java.lang.String getTitle()
          Get a new title
static void main(java.lang.String[] args)
          Test
 PND oper(PND pnd, java.lang.String what)
          Operations on PND containers: add, subtract, multiply, divide.
 PND oper(PND pnd, java.lang.String title, java.lang.String what)
          Operations on PND containers: add, subtract, multiply, divide.
 PND operScale(PND pnd, double scale)
          Scale each element of data
 void print()
          Print PND to System.out.
 PND read(java.lang.String sfile)
          Read the data from external file.
 PND remove(int index)
          Remove a row
 void set(int index, double[] values)
          Sets (replace) the specified element.
 void set(int index, P0D values)
          Sets (replace) the specified element with P0D.
 PND setArray(double[][] values)
          Set values from double array Old content will be lost.
 void setArrayList(java.util.ArrayList<double[]> array)
          Set the data in form of ArrayList
 void setTitle(java.lang.String title)
          Set a new title
 int size()
          Data size (number of rows)
 void toFile(java.lang.String name)
          Write a PND to an external file.
 java.lang.String toString()
          Get a string representing PND
 void write(java.lang.String name)
          Write a PND to an external file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PND

public PND(java.lang.String title)
Construct an empty container with a title

Parameters:
title - A title

PND

public PND(java.lang.String title,
           boolean shallow,
           PND pnd)
Construct a copy from a PND. If the last argument is true, a shallow copy of a collection. In this case a new collection contains references to same objects as the source collection. Data are not cloned

Parameters:
title - new title
shallow - if true, a shallow copy of a collection.
pnd - inpit data

PND

public PND(java.lang.String title,
           java.lang.String file)
Construct a container with a title from external file (see the method toFile() how to write such ASCII file)

Parameters:
title - A title
file - input file name

PND

public PND()
Construct an empty container with no title

Method Detail

setTitle

public void setTitle(java.lang.String title)
Set a new title

Parameters:
title - New Title

getTitle

public java.lang.String getTitle()
Get a new title

Returns:
Title

clear

public void clear()
Clear the container


get

public double[] get(int row)
Return a specific row as array

Parameters:
row - index of the row
Returns:
array of values

get

public double get(int row,
                  int column)
Return a specific value.

Parameters:
row - row index
column - column index
Returns:
value

toString

public java.lang.String toString()
Get a string representing PND

Overrides:
toString in class java.lang.Object
Returns:
String with all values

print

public void print()
Print PND to System.out.


getColumn

public P0D getColumn(int column)
Return a specific row as array

Parameters:
column - index of the row
Returns:
P0D array with values.

getDimension

public int getDimension()
Get last dimension of the data.

Returns:
dimension (number of elements in a row)

getRow

public P0D getRow(int row)
Return a specific row as array

Parameters:
row - index of the row
Returns:
array of values

getArrayList

public java.util.ArrayList<double[]> getArrayList()
Get data in form of ArrayList

Returns:
data in form of ArrayList

add

public void add(double[] values)
Adds (appends) the specified element to the end of this list.

Parameters:
values - array of values to be added.

add

public void add(P0D values)
Adds (appends) P0D to the end of this list.

Parameters:
values - array of values to be added.

set

public void set(int index,
                double[] values)
Sets (replace) the specified element.

Parameters:
index - position index
values - array of values to be added.

set

public void set(int index,
                P0D values)
Sets (replace) the specified element with P0D.

Parameters:
index - position index
values - array of values to be added.

read

public PND read(java.lang.String sfile)
Read the data from external file. Old data will be lost.

Parameters:
sfile - File name with input
Returns:
PND with new data.

write

public void write(java.lang.String name)
Write a PND to an external file. Same method as toFile()

Parameters:
name - File name with output

toFile

public void toFile(java.lang.String name)
Write a PND to an external file.

Parameters:
name - File name with output

remove

public PND remove(int index)
Remove a row

Parameters:
index - row index to be removed

oper

public PND oper(PND pnd,
                java.lang.String what)
Operations on PND containers: add, subtract, multiply, divide. Keep the same graphical attributes and title.

Parameters:
pnd - Input PND container for operation
what - String representing the operation: "+" add a P0D container to the original; "-" subtract a P0D from the original; "*" multiply; "/" divide by P0D
Returns:
original PND after the operation.

oper

public PND oper(PND pnd,
                java.lang.String title,
                java.lang.String what)
Operations on PND containers: add, subtract, multiply, divide. Keep the same graphical attributes

Parameters:
pnd - Input PND container for operation
title - New title
what - String representing the operation: "+" add a P0D container to the original; "-" subtract a P0D from the original; "*" multiply; "/" divide by P0D
Returns:
original PND after the operation.

operScale

public PND operScale(PND pnd,
                     double scale)
Scale each element of data

Parameters:
pnd - Input PND container for operation
scale - Scale factor
Returns:
original PND after scaling

size

public int size()
Data size (number of rows)

Returns:
number of rows

copy

public PND copy(java.lang.String newtitle)

setArrayList

public void setArrayList(java.util.ArrayList<double[]> array)
Set the data in form of ArrayList

Parameters:
array - ArrayList to be set.

getArray

public double[][] getArray()
Get a double array with values.

Returns:
double array with values

setArray

public PND setArray(double[][] values)
Set values from double array Old content will be lost.

Parameters:
values - array to be set: [ROWS][dimension];
Returns:
PND with new values

main

public static void main(java.lang.String[] args)
Test

Parameters:
args -


jHepWork 1.1 (C) Chekanov