// // SingletonSet.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; import java.rmi.*; /** SingletonSet is the class for Set-s containing one member.argument (if * non-*/ public class SingletonSet extends SampledSet { private static final long serialVersionUID = 1L; private RealTuple data; private static final int[] nilNeighbors = {}; /** * Construct a SingletonSet with the single sample given by a RealTuple * * @param d sample as a RealTuple * @throws VisADException Couldn't create the necessary VisAD object * @throws RemoteException Couldn't create the necessary remote object */ public SingletonSet(RealTuple d) throws VisADException, RemoteException { this(d, d.getType(), null, d.getTupleUnits(), null); } /** * Construct a SingletonSet with the single sample given by a RealTuple, * and a non-default CoordinateSystem, Units and ErrorEstimates. * * @param d sample as a RealTuple * @param coord_sys CoordinateSystem * @param units Units * @param errors ErrorEstimate * * @throws VisADException Couldn't create the necessary VisAD object * @throws RemoteException Couldn't create the necessary remote object */ public SingletonSet(RealTuple d, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors) throws VisADException, RemoteException { this(d, d.getType(), coord_sys, units, errors); } /** construct a SingletonSet with a different MathType than its RealTuple argument, and a non-default CoordinateSystem */ private SingletonSet(RealTuple d, MathType type, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors) throws VisADException, RemoteException { super(type, 0, coord_sys, units, errors); // ManifoldDimension = 0 int dim = d.getDimension(); float[][] samples = new float[dim][1]; for (int k=0; k
* units null); otherwise, in units of * the coordinate system argument (if non- *null); otherwise, in the * default units of the type argument. * @param coordSys The coordinate system transformation for this * instance ornull. * @param units The units of the numeric values or* null. * @param errors Error estimates for the values or* null. * @throws VisADException if a VisAD failure occurs. * @throws RemoteException if a Java RMI failure occurs. * @throws NullPointerException if the type or values argument is *null. * @see CoordinateSystem#getCoordinateSystemUnits() */ public SingletonSet(RealTupleType type, double[] values, CoordinateSystem coordSys, Unit[] units, ErrorEstimate[] errors) throws VisADException, RemoteException { super(type, 0, coordSys, units, errors); // ManifoldDimension = 0 int dim = type.getDimension(); float[][] samples = new float[dim][1]; Real[] reals = new Real[dim]; units = getSetUnits(); errors = getSetErrors(); for (int k=0; kReturns an array of indexes for neighboring points for each point in the * set. If neighborsis the return value, then *neighbors[i][j]is the index of thejth * neighbor of samplei. * *This implementation places an array of length zero into the single * element of the input array. The length is zero because instances of this * class have no neighboring sample points.
* * @param neighbors The array to hold the indicial arrays for * each sample point. * @throws ArrayIndexOutOfBoundsException * if the length of the argument array is zero. */ public void getNeighbors(int[][] neighbors) { neighbors[0] = nilNeighbors; } /** * convert an array of 1-D indices to an array of values in R^DomainDimension * * @return float array of values * @throws VisADException couldn't create the necessary VisAD object */ public float[][] indexToValue(int[] index) throws VisADException { return Set.doubleToFloat(indexToDouble(index)); } /** * convert an array of 1-D indices to an array of doubles in R^DomainDimension * * @return double array of values * @throws VisADException couldn't create the necessary VisAD object */ public double[][] indexToDouble(int[] index) throws VisADException { int length = index.length; double[][] value = new double[DomainDimension][length]; double[] v = new double[DomainDimension]; for (int k=0; k= Length) { for (int k=0; k
Ads help maintain this website.