-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector.java
More file actions
40 lines (38 loc) · 1.19 KB
/
Vector.java
File metadata and controls
40 lines (38 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Created by Brendan C. Reidy
// Created on April 26, 2019
// Vector Object
// Desc: These objects are essentially just arrays of floats, but their functionality allows for any type of input to be
// converted into a float array. These arrays are then stored in a Matrix2D to allow for Matrices with varying lengths at each index
// Last Modified 4/26/19
public class Vector {
float[] pair;
int length;
public Vector(float[] set){
this.pair = set;
this.length = set.length;
}
public Vector(int[] set){
float[] emptySet = new float[set.length];
for(int i=0; i<set.length; i++)
emptySet[i] = (float) set[i];
this.pair = emptySet;
this.length = set.length;
}
public Vector(double[] set){
float[] emptySet = new float[set.length];
for(int i=0; i<set.length; i++)
emptySet[i] = (float) set[i];
this.pair = emptySet;
this.length = set.length;
}
public void set(float value, int index){
pair[index]=value;
}
public float[] toArray(){
return this.pair;
}
public String toString(){
String str = pair.toString();
return str;
}
}