package jeranvier.math.linearAlgebra;

import jeranvier.math.util.Complex;

public class Vector extends Matrix{
	
	public Vector(Complex[][] data){
		super(data);
		if(data.length !=1){
			throw new IllegalArgumentException();
		}
	}
	
	public int size(){
		return this.data[0].length;
	}
	
	public Complex get(int column){
		return this.data[0][column-1];
	}
	
	

	@Override
	public Vector entrywiseMultiplyBy(Matrix that) throws IllegalArgumentException {
		return new Vector(super.entrywiseMultiplyBy(that).data);
	}
	
	public Complex dot(Vector that) throws IllegalArgumentException {
		if(!sameDimension(this, that)){
			throw new IllegalArgumentException();
		}
		Complex sum = new Complex();
		for(int i=1; i<=this.columns; i++){
			sum = sum.add(this.get(i).multiplyBy(that.get(i)));
		}
		return sum;
	}

	public static final class Builder extends Matrix.Builder{
		
		public Builder(int size){
			super(1, size);
		}
		
		public Builder(Complex[][] data){
			super(data);
			if(data.length !=1){
				throw new IllegalArgumentException();
			}
		}
		
		public Builder(Vector vector) {
			super(vector.data);
		}
		
		public Builder(Complex[] line){
			super(1, line.length);
			this.data[0] = line;
		}

		public void set(int column, Complex value){
			this.data[0][column-1] = value;
		}
		
		public void set(int column, double value){
			this.data[0][column-1] = new Complex(value, 0d);
		}
		
		public Complex get(int column){
			return this.data[0][column-1];
		}
		
		public Vector build(){
			return new Vector(data);
		}
	}

	public static Vector zeros(int size) {
		Builder b = new Builder(size);
		for(int i=1; i<=size; i++){
			b.set(i, 0);
		}
		return b.build();
	}

}

@@ -32,16 +32,69 @@
 gebra;%0A%0A
+import java.util.Arrays;%0Aimport java.util.Iterator;%0A%0A
 import j
@@ -156,16 +156,45 @@
 s Matrix
+ implements Iterable%3CComplex%3E
 %7B%0A%09%0A%09pub
@@ -437,16 +437,216 @@
 %5D;%0A%09%7D%0A%09%0A
+%09public Vector getRange(int min, int max)%7B%0A%09%09Vector.Builder vb = new Vector.Builder(max - min +1);%0A%09%09for(int i = min; i %3C= max; i++)%7B%0A%09%09%09vb.set(i-min+1, this.get(i));%0A%09%09%7D%0A%09%09%0A%09%09return vb.build();%0A%09%7D%0A%09%0A
 %09%0A%0A%09@Ove
@@ -1108,14 +1108,8 @@
 tic 
-final 
 clas
@@ -1957,10 +1957,108 @@
 ();%0A%09%7D%0A%0A
+%09@Override%0A%09public Iterator%3CComplex%3E iterator() %7B%0A%09%09return Arrays.asList(data%5B0%5D).iterator();%0A%09%7D%0A%0A
 %7D%0A

fix inner class definition for Vector builder