view src/samer/units/Stacker2.java @ 8:5e3cbbf173aa tip

Reorganise some more
author samer
date Fri, 05 Apr 2019 22:41:58 +0100
parents bf79fb79ee13
children
line wrap: on
line source
/*
 *	Copyright (c) 2000, Samer Abdallah, King's College London.
 *	All rights reserved.
 *
 *	This software is provided AS iS and WITHOUT ANY WARRANTY; 
 *	without even the implied warranty of MERCHANTABILITY or 
 *	FITNESS FOR A PARTICULAR PURPOSE.
 */

package samer.units;
import  samer.core.*;
import  samer.maths.*;
import  samer.tools.*;

/*
 *		Takes successive input vectors and stacks them into
 *		one big output vector. This version only stacks one
 *		at new vector at a time and therefore does not need a
 *		sub task to run to get new vectors.
 */

public class Stacker2 extends NullTask
{
	Node	node;
	Vec	srcvec;
	VVector	target;
	double []	a;
	int	k0, k1, k2;

	public Stacker2(Vec v, int size) { this(v,size,v.size()); }
	public Stacker2(Vec v, int size, int height)
	{
		node = new Node("stacker");

		Shell.push(node);
		srcvec=v; 

		k0=height;
		k1=k0;
		k2=(size-1)*k0;

		target = new VVector("output",k0*size);
		a = target.array();
		Mathx.zero(a);

		Shell.pop();
	}

	public void dispose() { target.dispose(); }
	public VVector output() { return target; }

	public void run() {
		System.arraycopy(a,k1,a,0,k2); // make some room 
		System.arraycopy(srcvec.array(),0,a,k2,k0); // copy new data in
		target.changed();
	}
}