package org.nd4j.examples;

import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.Nd4j;

/**
 * Created by cvn on 9/6/14.
 */
public class ElementWiseOperationExample {

    public static void main(String[] args) {

        INDArray nd = Nd4j.create(new float[]{1,2,3,4},new int[]{2,2});
        System.out.println("Here's your initial matrix.");
        System.out.println(nd);
         nd.addi(1);
        System.out.println("Add 1 to each element with nd.addi(1);");
        System.out.println(nd);
         nd.muli(5);
        System.out.println("Multiply each element by 5 with nd.muli(5);");
        System.out.println(nd);
         nd.subi(3);
        System.out.println("Subtract 3 from each element with nd.subi(3);");
         System.out.println(nd);
        nd.divi(2);
        System.out.println("Divide each element by 2 with nd.divi(2);");
        System.out.println(nd);

    }

}
@@ -141,16 +141,18 @@
 14.%0A */%0A
+ %0A
 public c
@@ -317,56 +317,308 @@
     
-System.out.println(%22Here's your initial matrix.%22
+INDArray nd2 = Nd4j.create(new float%5B%5D%7B5,6%7D,new int%5B%5D%7B2,1%7D); //vector as column%0A        INDArray nd3 = Nd4j.create(new float%5B%5D%7B5,6%7D,new int%5B%5D%7B2%7D); //vector as row%0A        INDArray nd4 = Nd4j.create(new float%5B%5D%7B5,6,7,8%7D,new int%5B%5D%7B2,2%7D);%0A%0A        // Show initial matrices%0A%0A        System.out.println(nd
 );%0A 
@@ -637,32 +637,33 @@
 m.out.println(nd
+2
 );%0A         nd.a
@@ -657,26 +657,38 @@
         
- nd.addi(1
+System.out.println(nd3
 );%0A     
@@ -713,50 +713,191 @@
 tln(
-%22Add 1 to each element with
+nd4);%0A%0A        //create nd-array variable ndv to be able to print result of nondestructive operations. add scalar to matrix and assign ndv the sum.%0A%0A        INDArray ndv =
  nd.add
-i
 (1);
-%22);
+%0A
 %0A   
@@ -918,35 +918,37 @@
 t.println(nd
+v
 );%0A
+%0A
         
  nd.muli(5);
@@ -935,24 +935,28 @@
         
+ndv =
  nd.mul
-i
 (5);%0A   
@@ -983,53 +983,37 @@
 tln(
-%22Multiply each element by 5 with nd.muli(5);%22
+ndv);%0A%0A        ndv = nd.sub(3
 );%0A 
@@ -1040,27 +1040,29 @@
 intln(nd
+v
 );%0A
+%0A
         
  nd.subi
@@ -1053,26 +1053,30 @@
         
- nd.subi(3
+ndv = nd.div(2
 );%0A     
@@ -1101,59 +1101,94 @@
 tln(
-%22Subtract 3 from each element with nd.subi(3);%22);%0A 
+ndv);%0A%0A        //add column vector to matrix%0A%0A        ndv = nd.addColumnVector(nd2);%0A%0A
     
@@ -1212,27 +1212,29 @@
 intln(nd
+v
 );%0A
+%0A
         
 nd.divi(
@@ -1229,20 +1229,74 @@
     
-nd.divi(2
+// add row vector to matrix%0A%0A        ndv = nd.addRowVector(nd3
 );%0A
+%0A
     
@@ -1322,54 +1322,109 @@
 tln(
-%22Divide each element by 2 with nd.divi(2);%22
+ndv);%0A%0A        //multiply two matrices of equal dimensions elementwise.%0A%0A        ndv = nd.mul(nd4
 );%0A
+%0A
     
@@ -1448,16 +1448,17 @@
 intln(nd
+v
 );%0A%0A    
@@ -1461,8 +1461,9 @@
     %7D%0A%0A%7D
+%0A

Update ElementWiseOperationExample.java