lphy.base.function.Copy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lphy-base Show documentation
Show all versions of lphy-base Show documentation
The standard library of LPhy, which contains the required generative distributions and basic functions.
The newest version!
package lphy.base.function;
import lphy.core.model.DeterministicFunction;
import lphy.core.model.annotation.GeneratorInfo;
import lphy.core.model.annotation.ParameterInfo;
import lphy.core.model.Value;
public class Copy extends DeterministicFunction {
private final String xParamName = "val";
private Value x;
public Copy(@ParameterInfo(name = xParamName,
description = "the value to replicate.") Value x) {
this.x = x;
if (x == null) throw new IllegalArgumentException("The value can't be null!");
setParam(xParamName, x);
}
@GeneratorInfo(name = "copy", description = "Replicate a value. " +
"When combining with 'replicates=n', it is equivalent to replicate the value n times.")
public Value apply() {
Value value = getParams().get(xParamName);
return new Value<>( null, value.value(), this);
}
}