From c97108da27c86747aed72a7b935056067895351e Mon Sep 17 00:00:00 2001
From: "tanguy.dietrich" <tanguy.dietrich@etu.hesge.ch>
Date: Wed, 16 Oct 2019 17:53:09 +0200
Subject: [PATCH] Ajout de Zeros, et modification de memo

---
 memo_git.txt                                |  7 +++++--
 src/main/java/ch/hepia/numeric/Vector.java  | 17 ++++++++++++++---
 src/test/java/ch/hepia/numeric/AppTest.java | 15 +++++++++------
 3 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/memo_git.txt b/memo_git.txt
index b92e1b4..f62153e 100644
--- a/memo_git.txt
+++ b/memo_git.txt
@@ -1,6 +1,9 @@
 recupere l'etat actuel du projet a partir de git
 >git clone https://githepia.hesge.ch/david.carballo/poo2019numeric
 
+Changement de branche
+>git checkout -b NomBranche
+
 ajoute les nouvelle modification
 >git add .
 
@@ -13,5 +16,5 @@ modifie le git
 
 AUTRE :
 
-verifie si il y a des changement 
->git diff
\ No newline at end of file
+verifie si il y a des changement
+>git diff
diff --git a/src/main/java/ch/hepia/numeric/Vector.java b/src/main/java/ch/hepia/numeric/Vector.java
index 80134cf..f57da4e 100644
--- a/src/main/java/ch/hepia/numeric/Vector.java
+++ b/src/main/java/ch/hepia/numeric/Vector.java
@@ -124,7 +124,13 @@ final public class Vector {
     }
 
     public static Vector of(List<Double> elements) {
-        throw new UnsupportedOperationException("This feature isn't implemented yet");
+        //throw new UnsupportedOperationException("This feature isn't implemented yet");
+        Vector v = new Vector();
+         for(double e:elements)
+         {
+           v.lstVector.add(e);
+         }
+         return v;
     }
 
     public static Vector empty() {
@@ -138,7 +144,13 @@ final public class Vector {
     }
 
     public static Vector zeros(int nb) {
-        throw new UnsupportedOperationException("This feature isn't implemented yet");
+      Vector v = new Vector();
+      for(int i=0;i<nb;i++)
+      {
+        v.lstVector.add(0.0);
+      }
+      return v;
+        //throw new UnsupportedOperationException("This feature isn't implemented yet");
     }
 
     public static Vector ones(int nb) {
@@ -183,7 +195,6 @@ final public class Vector {
 /*
     @Override
     public boolean equals(Object obj) {
-
       if(this instanceof ch.hepia.numeric.Vector)
       {
         for(int i=0;i<this.lstVector.size();i++)//a ameliorer avec for(e:element)
diff --git a/src/test/java/ch/hepia/numeric/AppTest.java b/src/test/java/ch/hepia/numeric/AppTest.java
index eb2ed6a..174c91b 100644
--- a/src/test/java/ch/hepia/numeric/AppTest.java
+++ b/src/test/java/ch/hepia/numeric/AppTest.java
@@ -17,26 +17,29 @@ class VectorTest {
         Vector v3 = Vector.of(-1.0, -2.0, -3.0);
         //Transposed t1= new Transposed(v2);
         //System.out.println(v1.toString());
+        //assertEquals(v1.add(v2), Vector.of(0.0, 0.0, 0.0));
         assertEquals(v1.add(v2).toString(), Vector.of(0.0, 0.0, 0.0).toString());
         assertEquals(v1.sub(v2).toString(), Vector.of(2.0, 4.0, 6.0).toString());
         assertEquals(v1.mul(3.0).toString(), Vector.of(3.0, 6.0, 9.0).toString());
         assertEquals(Vector.empty().len(), 0);
         assertEquals(Vector.of(1.0, 2.0, 1.0).len(), 3);
     }
-/*
+
     @Test
     void vectorCreation() {
-        assertEquals(Vector.zeros(3), Vector.of(0.0, 0.0, 0.0));
-        assertEquals(Vector.ones(3), Vector.of(1.0, 1.0, 1.0));
-        assertEquals(Vector.of(1.0, 2.0).map( d -> d * 2.0), Vector.of(2.0, 4.0));
-        assertEquals(Vector.fill(3, 1.7), Vector.of(1.7, 1.7, 1.7));
-        assertEquals(Vector.tabulate(4, i -> i*5.0), Vector.of(0.0, 5.0, 10.0, 15.0));
+        assertEquals(Vector.zeros(3).toString(), Vector.of(0.0, 0.0, 0.0).toString());
+        //assertEquals(Vector.ones(3), Vector.of(1.0, 1.0, 1.0));
+        //assertEquals(Vector.of(1.0, 2.0).map( d -> d * 2.0), Vector.of(2.0, 4.0));
+        //assertEquals(Vector.fill(3, 1.7), Vector.of(1.7, 1.7, 1.7));
+        //assertEquals(Vector.tabulate(4, i -> i*5.0), Vector.of(0.0, 5.0, 10.0, 15.0));
     }
+/*
     @Test
     void vectorLinespace() {
         assertEquals(Vector.linespace(0.0, 1.0, 3), Vector.of(0.0, 0.5, 1.0));
         assertEquals(Vector.linespace(0.0, 1.0, 5), Vector.of(0.0, 0.25, 0.5, 0.75, 1.0));
     }
+
     @Test
     void vectorNormAndSum() {
         assertEquals(Vector.of(1.0, 2.0, 2.0).norm(), 3.0);
-- 
GitLab