Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
poo2019numeric
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steven.liatti
poo2019numeric
Commits
c97108da
Commit
c97108da
authored
5 years ago
by
tanguy.dietrich
Browse files
Options
Downloads
Patches
Plain Diff
Ajout de Zeros, et modification de memo
parent
df19a236
No related branches found
No related tags found
1 merge request
!2
Tanguy
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
memo_git.txt
+5
-2
5 additions, 2 deletions
memo_git.txt
src/main/java/ch/hepia/numeric/Vector.java
+14
-3
14 additions, 3 deletions
src/main/java/ch/hepia/numeric/Vector.java
src/test/java/ch/hepia/numeric/AppTest.java
+9
-6
9 additions, 6 deletions
src/test/java/ch/hepia/numeric/AppTest.java
with
28 additions
and
11 deletions
memo_git.txt
+
5
−
2
View file @
c97108da
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
This diff is collapsed.
Click to expand it.
src/main/java/ch/hepia/numeric/Vector.java
+
14
−
3
View file @
c97108da
...
...
@@ -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)
...
...
This diff is collapsed.
Click to expand it.
src/test/java/ch/hepia/numeric/AppTest.java
+
9
−
6
View file @
c97108da
...
...
@@ -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);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment