-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExample3.java
More file actions
38 lines (25 loc) · 772 Bytes
/
Example3.java
File metadata and controls
38 lines (25 loc) · 772 Bytes
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
package applications.numerics;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.Nd4j;
public class Example3 {
public static void main(String[] args){
// create an 1D row vector
INDArray x = Nd4j.create(new double[]{2.0, 3.0, 52.0});
// view the array
System.out.println(x);
// now that we have our vector set we can
// do various operations on it
// add 2 to every element
x.addi(2.0);
System.out.println(x);
// subtract 5.0
x.subi(5.0);
System.out.println(x);
// multiply with 10.0
x.muli(10.0);
System.out.println(x);
// divide with 3.0
x.divi(3.0);
System.out.println(x);
}
}