// constructor that sorts (artificial boolean flag) private InterpolatedNodalSurface(SurfaceMetadata metadata, DoubleArray xValues, DoubleArray yValues, DoubleArray zValues, SurfaceInterpolator interpolator, bool sort) { validateInputs(metadata, xValues, yValues, zValues, interpolator); // sort inputs IDictionary <DoublesPair, ObjDoublePair <ParameterMetadata> > sorted = new SortedDictionary <DoublesPair, ObjDoublePair <ParameterMetadata> >(); for (int i = 0; i < xValues.size(); i++) { ParameterMetadata pm = metadata.getParameterMetadata(i); sorted[DoublesPair.of(xValues.get(i), yValues.get(i))] = ObjDoublePair.of(pm, zValues.get(i)); } double[] sortedX = new double[sorted.Count]; double[] sortedY = new double[sorted.Count]; double[] sortedZ = new double[sorted.Count]; ParameterMetadata[] sortedPm = new ParameterMetadata[sorted.Count]; int pos = 0; foreach (KeyValuePair <DoublesPair, ObjDoublePair <ParameterMetadata> > entry in sorted.SetOfKeyValuePairs()) { sortedX[pos] = entry.Key.First; sortedY[pos] = entry.Key.Second; sortedZ[pos] = entry.Value.Second; sortedPm[pos] = entry.Value.First; pos++; } // assign SurfaceMetadata sortedMetadata = metadata.withParameterMetadata(Arrays.asList(sortedPm)); this.metadata = sortedMetadata; this.xValues = DoubleArray.ofUnsafe(sortedX); this.yValues = DoubleArray.ofUnsafe(sortedY); this.zValues = DoubleArray.ofUnsafe(sortedZ); IDictionary <DoublesPair, double> pairs = new Dictionary <DoublesPair, double>(); for (int i = 0; i < xValues.size(); i++) { pairs[DoublesPair.of(xValues.get(i), yValues.get(i))] = zValues.get(i); } this.interpolator = interpolator; this.boundInterpolator = interpolator.bind(this.xValues, this.yValues, this.zValues); this.parameterMetadata = IntStream.range(0, ParameterCount).mapToObj(i => sortedMetadata.getParameterMetadata(i)).collect(toImmutableList()); }
//------------------------------------------------------------------------- public ConstantSurface withMetadata(SurfaceMetadata metadata) { return(new ConstantSurface(metadata.withParameterMetadata(null), zValue_Renamed)); }