//
// LinearNDSet.java
//

/*
VisAD system for interactive analysis and visualization of numerical
data.  Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/

package visad;

/**
   LinearNDSet represents a finite set of samples of R^Dimension
   in a cross product of arithmetic progressions.

The order of the samples is the rasterization of the orders of the 1D components, with the first component increasing fastest. For more detail, see the example in Linear2DSet.java.

*/ public class LinearNDSet extends GriddedSet implements LinearSet { Linear1DSet[] L; private boolean cacheSamples = false; /** * Construct an N-dimensional set as the product of N Linear1DSets, * with null errors, CoordinateSystem and Units are defaults from * type. * @param type MathType for this LinearNDSet. Must be consistent * with MathType-s of sets. * @param l Linear1DSets that make up this LinearNDSet. * @throws VisADException problem creating VisAD objects. */ public LinearNDSet(MathType type, Linear1DSet[] l) throws VisADException { this(type, l, null, null, null); } /** * Construct an N-dimensional set as the product of N arithmetic * progressions (lengths[i] samples between firsts[i] and lasts[i]), * with null errors, CoordinateSystem and Units are defaults from type * @param type MathType for this LinearNDSet. * @param firsts array of first values for each of the * arithmetic progressions * @param lasts array of last values for each of the * arithmetic progressions * @param lengths array of number of samples for each of the * arithmetic progressions * @throws VisADException problem creating VisAD objects. */ public LinearNDSet(MathType type, double[] firsts, double[] lasts, int[] lengths) throws VisADException { this(type, get_linear1d_array(type, firsts, lasts, lengths, null), null, null, null); } /** * Construct an N-dimensional set as the product of N arithmetic * progressions (lengths[i] samples between firsts[i] and lasts[i]), * coordinate_system and units must be compatible with defaults for * type, or may be null; errors may be null. * @param type MathType for this LinearNDSet. * @param firsts array of first values for each of the * arithmetic progressions * @param lasts array of last values for each of the * arithmetic progressions * @param lengths array of number of samples for each of the * arithmetic progressions * @param coord_sys CoordinateSystem for this set. May be null, but * if not, must be consistent with type. * @param units Unit-s for the values in sets. May * be null, but must be convertible with default of * type if not null. * @param errors ErrorEstimate-s for values in sets, * may be null * @throws VisADException problem creating VisAD objects. */ public LinearNDSet(MathType type, double[] firsts, double[] lasts, int[] lengths, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors) throws VisADException { this(type, firsts, lasts, lengths, coord_sys, units, errors, false); } /** * Construct an N-dimensional set as the product of N arithmetic * progressions (lengths[i] samples between firsts[i] and lasts[i]), * coordinate_system and units must be compatible with defaults for * type, or may be null; errors may be null. * @param type MathType for this LinearNDSet. * @param firsts array of first values for each of the * arithmetic progressions * @param lasts array of last values for each of the * arithmetic progressions * @param lengths array of number of samples for each of the * arithmetic progressions * @param coord_sys CoordinateSystem for this set. May be null, but * if not, must be consistent with type. * @param units Unit-s for the values in sets. May * be null, but must be convertible with default of * type if not null. * @param errors ErrorEstimate-s for values in sets, * may be null * @param cache if true, enumerate and cache the samples. This will * result in a larger memory footprint, but will * reduce the time to return samples from calls to * {@link #getSamples()}. * @throws VisADException problem creating VisAD objects. */ public LinearNDSet(MathType type, double[] firsts, double[] lasts, int[] lengths, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors, boolean cache) throws VisADException { this(type, get_linear1d_array(type, firsts, lasts, lengths, units), coord_sys, units, errors, cache); } /** * Construct an N-dimensional set as the product of N Linear1DSets; * coordinate_system and units must be compatible with defaults * for type, or may be null; errors may be null * @param type MathType for this LinearNDSet. Must be consistent * with MathType-s of sets. * @param l Linear1DSets that make up this LinearNDSet. * @param coord_sys CoordinateSystem for this set. May be null, but * if not, must be consistent with type. * @param units Unit-s for the values in sets. May * be null, but must be convertible with default of * type if not null. * @param errors ErrorEstimate-s for values in sets, * may be null * @throws VisADException problem creating VisAD objects. */ public LinearNDSet(MathType type, Linear1DSet[] l, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors) throws VisADException { this(type, l, coord_sys, units, errors, false); } /** * Construct an N-dimensional set as the product of N Linear1DSets; * coordinate_system and units must be compatible with defaults * for type, or may be null; errors may be null * @param type MathType for this LinearNDSet. Must be consistent * with MathType-s of sets. * @param l Linear1DSets that make up this LinearNDSet. * @param coord_sys CoordinateSystem for this set. May be null, but * if not, must be consistent with type. * @param units Unit-s for the values in sets. May * be null, but must be convertible with default of * type if not null. * @param errors ErrorEstimate-s for values in sets, * may be null * @param cache if true, enumerate and cache the samples. This will * result in a larger memory footprint, but will * reduce the time to return samples from calls to * {@link #getSamples()}. * @throws VisADException problem creating VisAD objects. */ public LinearNDSet(MathType type, Linear1DSet[] l, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors, boolean cache) throws VisADException { super(type, null, get_lengths(l), coord_sys, LinearNDSet.units_array_linear1d(l, units), errors); if (DomainDimension != ManifoldDimension) { throw new SetException("LinearNDSet: DomainDimension != ManifoldDimension"); } L = LinearNDSet.linear1d_array_units(l, units); for (int j=0; j j) us[0] = units[j]; l[j] = new Linear1DSet(set_type, firsts[j], lasts[j], lengths[j], null, us, null); } return l; } static Linear1DSet[] get_linear1d_array(MathType type, double first1, double last1, int length1, double first2, double last2, int length2, Unit[] units) throws VisADException { double[] firsts = {first1, first2}; double[] lasts = {last1, last2}; int[] lengths = {length1, length2}; return get_linear1d_array(type, firsts, lasts, lengths, units); } static Linear1DSet[] get_linear1d_array(MathType type, double first1, double last1, int length1, double first2, double last2, int length2, double first3, double last3, int length3, Unit[] units) throws VisADException { double[] firsts = {first1, first2, first3}; double[] lasts = {last1, last2, last3}; int[] lengths = {length1, length2, length3}; return get_linear1d_array(type, firsts, lasts, lengths, units); } /** convert an array of 1-D indices to an array of values in R^DomainDimension */ public float[][] indexToValue(int[] index) throws VisADException { int dim = getDimension(); int length = index.length; int[][] indexN = new int[dim][length]; float[][] values = new float[dim][]; int[] lengthN = new int[dim]; for (int j=0; j 1) { for (j=0; j 1"); } } } int length = grid[0].length; float[][][] gridJ = new float[DomainDimension][1][]; float[][][] valueJ = new float[DomainDimension][][]; for (j=0; j 1) { for (j=0; j 1"); } } } int length = value[0].length; float[][][] valueJ = new float[DomainDimension][1][]; float[][][] gridJ = new float[DomainDimension][][]; for (j=0; jset is a LinearNDSet and each * of the Linear1DSet-s that make up this cross product * are equal. */ public boolean equals(Object set) { if (!(set instanceof LinearNDSet) || set == null) return false; if (this == set) return true; if (!equalUnitAndCS((Set) set)) return false; if (DomainDimension != ((LinearNDSet) set).getDimension()) return false; for (int j=0; jtype. * @throws VisADException if type is not compatible * with MathType of component Linear1DSets. */ public Object cloneButType(MathType type) throws VisADException { Linear1DSet[] l = new Linear1DSet[DomainDimension]; for (int j=0; j

Ads help maintain this website.