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

com.meliorbis.numerics.generic.impl.NaryOpCallable Maven / Gradle / Ivy

Go to download

A library for working with large multi-dimensional arrays and the functions they represent

There is a newer version: 1.2
Show newest version
package com.meliorbis.numerics.generic.impl;

import com.meliorbis.numerics.NumericsException;
import com.meliorbis.numerics.generic.NaryOp;
import com.meliorbis.numerics.generic.SettableIterator;
import com.meliorbis.numerics.threading.ComputableRecursiveAction;

/**
 * Abstract Base class for callables that perform an nary op at each point on some iterators
 * 
 * @param T The input type, probably a numeric
 * @param E The type of exception thrown when things vo 
 */
public abstract class NaryOpCallable implements ComputableRecursiveAction
{
    protected final NaryOp _op;

    protected final SettableIterator _resultIter;
    protected final boolean _iterateResult;

    protected final SettableIterator[] _iterators;

    public NaryOpCallable(NaryOp op_,
                          SettableIterator[] inputs_,
                          SettableIterator result_,
                          boolean iterateResult_)
    {
        _op = op_;
        _iterators = inputs_;
        _resultIter = result_;
        _iterateResult = iterateResult_;
    }

    @Override
    public void compute()
    {
        try
        {
            while (_iterators[0].hasNext())
            {
                computeNextStep();
            }
        }
        catch(Exception ex_)
        {
        	throw new NumericsException(ex_);
        }
    }

    protected abstract void computeNextStep() throws E;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy