Mercurial > hg > jslab
view src/samer/units/Stacker.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. Requires a task which it will * run to obtain each input vector. */ public class Stacker implements Task { Node node; Task nextvec; Vec srcvec; int size, step; VVector target; double [] a, b; int k0, k1, k2; public Stacker(Vec v, Task t, int size, int step) { this(v,t,size,step,v.size()); } public Stacker(Vec v, Task t, int size, int step, int height) { node = new Node("stacker"); Shell.push(node); srcvec=v; nextvec=t; this.size = size; this.step = step; k0=height; k1=step*k0; k2=(size-step)*k0; target = new VVector("output",k0*size); a = target.array(); b = srcvec.array(); Mathx.zero(a); Shell.pop(); } public void dispose() { nextvec.dispose(); target.dispose(); a=b=null; } public VVector output() { return target; } public void starting() { nextvec.starting(); } public void stopping() { nextvec.stopping(); } public void run() throws Exception { // make some room in packed matrix System.arraycopy(a,k1,a,0,k2); for (int i=0, j=k2; i<step; i++) { nextvec.run(); // copy vec into packed matrix System.arraycopy(b,0,a,j,k0); j+=k0; } target.changed(); } }