com.softsynth.jmsl
Class DimensionNameSpaceTranslator

java.lang.Object
  extended by com.softsynth.jmsl.DimensionNameSpaceTranslator

public class DimensionNameSpaceTranslator
extends java.lang.Object

Translate an array of double from one DimensionNameSpace to another. Preserves as many values as possible by matching as many names as possible

Author:
Nick Didkovsky

Constructor Summary
DimensionNameSpaceTranslator()
           
 
Method Summary
 void addInvariant(int dim)
          Specify a dimension index that should be cross copied regardless of naming.
static void main(java.lang.String[] args)
           
 void setDestinationDimensionNameSpace(DimensionNameSpace dns)
           
 void setSourceDimensionNameSpace(DimensionNameSpace dns)
           
 double[] translate(double[] sourceDar)
          Copy as many values from source array to dest array as possible, pulling values by name.
 double[] translate(double[] sourceDar, double[] resultDar)
          Copy as many values from source array to dest array as possible, pulling values by name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DimensionNameSpaceTranslator

public DimensionNameSpaceTranslator()
Method Detail

addInvariant

public void addInvariant(int dim)
Specify a dimension index that should be cross copied regardless of naming. For example, if dimension 0 is always duration, addInvariant(0) and sourceArray[0] will be copied across to destArray[0] regardless of naming.


setSourceDimensionNameSpace

public void setSourceDimensionNameSpace(DimensionNameSpace dns)

setDestinationDimensionNameSpace

public void setDestinationDimensionNameSpace(DimensionNameSpace dns)

translate

public double[] translate(double[] sourceDar,
                          double[] resultDar)
Copy as many values from source array to dest array as possible, pulling values by name. Then run through dimension invariants and copy those across (for example dim 0 to dim 0) Other values set to destinationNameSpace.getDefault(dim)

Uses preallocated double[] for destination.

Returns:
modified resultDar, translated from source

translate

public double[] translate(double[] sourceDar)
Copy as many values from source array to dest array as possible, pulling values by name. Then run through dimension invariants and copy those across (for example dim 0 to dim 0) Other values set to Double.NEGATIVE_INFINITY

Allocates new double[] for destination.

Returns:
modified resultDar, translated from source

main

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