Home > jitter > setcell vs copyArrayToVectorPlanar method

setcell vs copyArrayToVectorPlanar method

Java/jitter offers two different ways to ‘fill up’ matrices: setcell and copyArrayToVectorPlanar. So far I find the second cleaner and more efficient. However, the criteria for their use might be related with the context of use. Herewith a small example of how to use setcell in order to create a random jitter matrix:


import com.cycling74.max.*;
import com.cycling74.jitter.*;
import java.util.Random;

public class SetMe extends MaxObject{
Random rrand;
JitterMatrix jl;
static final int PLANES=3;

public SetMe(){
//super();
//declareIO(1,2);
jl=new JitterMatrix(“hehe”,PLANES,”float32″,10,10);
this.rrand=new Random();
}

public void bang(){
this.calculateMe();
outlet(0,”jit_matrix”,jl.getName());
}

public void calculateMe(){
for(int k=0;k<PLANES;k++){
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
jl.setcell(new int[]{i,j},k,rrand.nextInt(10));
}
}
}
}
}

It is important to notice how copyArrayToVectorPlanar uses a single dimension loop to fill the matrix, whereas setcell requires two values to point the location of each one of the values. Maybe here is the bottleneck for this method?

Advertisements
Categories: jitter
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: