/** * This applies the KeywordSpecification validation and additionally checks * whether the given value has the correct length. * * {@inheritDoc } */ @Override public boolean validate(Value value) { return value == null || (super.validate(value) && ((VectorialValue) value).getVector().length == length); }
/** * Sets the actual vector. * * @param convertibleObject an object that can be converted to a double * array or a double scalar. */ public void setVector(@NonNull Object convertibleObject) { this.vector = mapToDoubleVector(convertibleObject); }
final Node node = new Node(sequences[s]); for (int k = 0; k < K; k++) { node.setValue(k, new VectorialValue(new double[]{arrays[s][i][k]}));
vector[n - startIdx] = arrays[s][i][n]; node.setValue(k, new VectorialValue(vector));
public V extractValue(@NonNull Node node) { final Value val = node.getValue(keyword); if (val == null) { return null; } switch (type) { case STRING: return (V) ((StringValue) val).getString(); case SYMBOLIC: return (V) ((SymbolicValue) val).getSymbol(); case VECTOR: return (V) ((VectorialValue) val).getVector(); default: throw new IllegalArgumentException("Unsupported ValueType: " + type); } }
for (int i = 0; i < arrays[s].length; i++) { final Node node = new Node(sequences[s]); node.setValue(0, new VectorialValue(arrays[s][i])); sequences[s].add(node);
public VectorialValue(@NonNull Object convertibleObject) { super(ValueType.VECTOR); this.vector = mapToDoubleVector(convertibleObject); }
final VectorialValue leftVal = (VectorialValue) op.getLeft(). getValue(spec.getOriginalIndex(k)); local_d = leftVal.getVector().length; System.arraycopy(leftVal.getVector(), 0, out[0][i], d, local_d); break; final VectorialValue rightVal = (VectorialValue) op.getRight(). getValue(spec.getOriginalIndex(k)); local_d = rightVal.getVector().length; System.arraycopy(rightVal.getVector(), 0, out[1][i], d, local_d); break;
/** * Transforms the given arrays to sequences. It is assumed that each * entry arrays[s] is a sequence. * Your sequences are allowed to have different lengths. * * @param arrays an array of double arrays that shall be converted to * sequences. * * @return an array of Sequences. */ public static Sequence[] toSequences(@NonNull double[][] arrays) { final KeywordSpecification[] keywordSpecs = {new VectorialKeywordSpecification(1, STDKEYWORD)}; final NodeSpecification nodeSpec = new NodeSpecification(keywordSpecs); final Sequence[] sequences = new Sequence[arrays.length]; for (int s = 0; s < arrays.length; s++) { sequences[s] = new Sequence(nodeSpec); for (int i = 0; i < arrays[s].length; i++) { final Node node = new Node(sequences[s]); node.setValue(0, new VectorialValue(new double[]{arrays[s][i]})); sequences[s].add(node); } } return sequences; }
content[d] = rand.nextGaussian(); node.setValue(k, new VectorialValue(content));