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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steven.liatti
poo2019numeric
Commits
acd989f8
Commit
acd989f8
authored
5 years ago
by
david
Browse files
Options
Downloads
Patches
Plain Diff
ajout des fonction slice -to -from
parent
d55ac700
No related branches found
No related tags found
2 merge requests
!2
Tanguy
,
!1
David
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
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
+3
-2
3 additions, 2 deletions
src/test/java/ch/hepia/numeric/AppTest.java
with
17 additions
and
5 deletions
src/main/java/ch/hepia/numeric/Vector.java
+
14
−
3
View file @
acd989f8
...
...
@@ -77,15 +77,26 @@ final public class Vector {
}
public
Vector
sliceFrom
(
int
i
)
{
throw
new
UnsupportedOperationException
(
"This feature isn't implemented yet"
);
return
slice
(
i
,
this
.
len
()
);
}
public
Vector
sliceTo
(
int
i
)
{
throw
new
UnsupportedOperationException
(
"This feature isn't implemented yet"
);
return
slice
(
0
,
i
);
}
public
Vector
slice
(
int
from
,
int
to
)
{
throw
new
UnsupportedOperationException
(
"This feature isn't implemented yet"
);
Vector
v
=
new
Vector
();
if
(
from
>=
to
){
return
v
;
}
else
{
for
(
double
d
:
this
.
lstVector
.
subList
(
from
,
to
))
{
v
.
lstVector
.
add
(
d
);
}
return
v
;
}
}
public
Vector
removed
(
int
i
)
{
...
...
This diff is collapsed.
Click to expand it.
src/test/java/ch/hepia/numeric/AppTest.java
+
3
−
2
View file @
acd989f8
...
...
@@ -74,7 +74,7 @@ class VectorTest {
assertEquals
(
v
.
toString
(),
"Vector[1.0, 2.0, 3.0]"
);
assertEquals
(
v
.
t
().
toString
(),
"Transposed[1.0, 2.0, 3.0]"
);
}
/*
@Test
void
vectorSlice
()
{
Vector
v
=
Vector
.
of
(
1.0
,
2.0
,
3.0
,
4.0
,
5.0
);
...
...
@@ -83,8 +83,9 @@ class VectorTest {
assertEquals
(
v
.
slice
(
2
,
4
),
Vector
.
of
(
3.0
,
4.0
));
assertEquals
(
v
.
slice
(
4
,
4
),
Vector
.
empty
());
assertEquals
(
v
.
slice
(
4
,
2
),
Vector
.
empty
());
assertEquals(v.removed(2), Vector.of(1.0, 2.0, 4.0, 5.0));
//
assertEquals(v.removed(2), Vector.of(1.0, 2.0, 4.0, 5.0));
}
/*
@Test
void vectorConcat() {
Vector v1 = Vector.of(1.0, 2.0, 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