All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lphy.base.function.Copy Maven / Gradle / Ivy

Go to download

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);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy