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

jadex.micro.examples.mandelbrot.ArrayTest Maven / Gradle / Ivy

Go to download

The Jadex micro applications package contains several example applications, benchmarks and testcases using micro agents.

There is a newer version: 4.0.267
Show newest version
package jadex.micro.examples.mandelbrot;

import java.util.Random;
import java.util.StringTokenizer;

import jadex.commons.Base64;
import jadex.xml.bean.JavaReader;
import jadex.xml.bean.JavaWriter;

/**
 *  Test ways of transferring short[][] arrays.
 *
 */
public class ArrayTest
{
	/**
	 * Get the data as a transferable string.
	 * 
	 * @return the data string.
	 */
	public static String shortToString(short[][] data)
	{
		String	ret	= null;
		if(data!=null)
		{
			// create string in form of "rows cols\n1 2\n4 5\n7 8"
			StringBuffer	sbuf	= new StringBuffer();
			sbuf.append(data.length);
			sbuf.append(" ");
			sbuf.append(data[0].length);
			sbuf.append("\n");
			for(short i=0; i0)
					sbuf.append("\n");
				for(short j=0; j0)
						sbuf.append(" ");
					sbuf.append(data[i][j]);
				}
			}
			ret	= sbuf.toString();
		}
		return ret;
	}

	/**
	 * Set the data.
	 * 
	 * @param data The data to set.
	 */
	public static short[][] stringToshort(String sdata)
	{
		StringTokenizer	stok	= new StringTokenizer(sdata);
		short	rows	= Short.parseShort(stok.nextToken());
		short	cols	= Short.parseShort(stok.nextToken());
		short[][]	data	= new short[rows][cols];
		for(short i=0; i>> 8);
		buffer[offset+1] = (byte)val;

		return buffer;
	}



	public static void	main(String[] args)
	{
		short[][]	data = new short[1234][1357];
		
		System.out.println("filling array...");
		Random	r	= new Random();
		for(short i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy