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

com.meliorbis.numerics.demo.ArrayDemo 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.demo;

import static com.meliorbis.numerics.DoubleArrayFactories.*;

import com.meliorbis.numerics.generic.primitives.DoubleArray;
import com.meliorbis.numerics.generic.primitives.DoubleBinaryOp;

public class ArrayDemo
{
	public static void main(String[] args_) {
		new ArrayDemo().run();
	}

	@SuppressWarnings("unchecked")
	private void run()
	{
		DoubleArray array = createArrayOfSize(2,3);

		array.fillDimensions(new double[] {.1,.2},0);

		// array contains:
		// .1, .1, .1
		// .2, .2, .1
		System.out.println(array);

		array.modifying().across(1).multiply(createArray(1,4,9));

		// array contains:
		// .1, .4, .9
		// .2, .8, 1.8
		System.out.println(array);
		
		array.modifying().across(0).with(createArray(.5,.5)).map(
				(DoubleBinaryOp)((double a, double b)-> a>b?a:0));
		
		// array contains:
		// 0,  0, .9
		// 0, .8, 1.8
		System.out.println(array);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy