package org.das2.qds; import org.das2.qds.ops.Ops; /** * Abstract class implements values and exampleOutput based on * value and exampleInput. * * @author jbf */ public abstract class AbstractQFunction implements QFunction { @Override public abstract QDataSet value(QDataSet parm); /** * calculate the values by calling the {@code value} function for * each element of {@code vs}. A check is made for each call to the {@code value} * function that a dataset with the same rank and length is returned. * @param vs rank N+1 set of values, where {@code exampleInput} returns rank N. * @return rank M+1 set of values, where {@code value} returns rank M. */ @Override public QDataSet values(QDataSet vs) { QDataSet v1= value( vs.slice(0) ); int rank= v1.rank(); int len= v1.length(); JoinDataSet result= new JoinDataSet( v1 ); WritableDataSet dep0ds=null; boolean haveDep0= false; if ( vs.rank()==2 && vs.length(0)==1 ) { // each value has one input dep0ds= ArrayDataSet.copy(Ops.slice1(vs,0)); QDataSet d1= (QDataSet)v1.property(QDataSet.CONTEXT_0); if ( d1!=null ) { dep0ds.putValue(0,d1.value()); dep0ds.putProperty(QDataSet.UNITS,d1.property(QDataSet.UNITS)); dep0ds.putProperty(QDataSet.LABEL,d1.property(QDataSet.LABEL)); dep0ds.putProperty(QDataSet.NAME,d1.property(QDataSet.NAME)); haveDep0= true; } } QDataSet bds= null; for ( int i=1; i