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
francois.hofer
poo2019numeric
Commits
af9d6d78
Commit
af9d6d78
authored
5 years ago
by
fefe
Browse files
Options
Downloads
Patches
Plain Diff
New function fill , tested
parent
9ef4a655
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/ch/hepia/numeric/Vector.java
+21
-1
21 additions, 1 deletion
src/main/java/ch/hepia/numeric/Vector.java
src/test/java/ch/hepia/numeric/AppTest.java
+7
-0
7 additions, 0 deletions
src/test/java/ch/hepia/numeric/AppTest.java
with
28 additions
and
1 deletion
src/main/java/ch/hepia/numeric/Vector.java
+
21
−
1
View file @
af9d6d78
...
...
@@ -189,7 +189,27 @@ final public class Vector {
public
static
double
norms
(
List
<
Vector
>
vs
)
{
return
Vector
.
sum
(
vs
).
norm
();
}
// FILL NEW VERSION :
public
static
SubVec
fill
(
int
nbr
){
return
new
Vector
().
new
SubVec
(
nbr
);
}
protected
class
SubVec
{
private
int
nbre
;
protected
SubVec
(
int
nbre
){
this
.
nbre
=
nbre
;
}
private
int
getNbre
(){
return
this
.
nbre
;
}
public
Vector
withValue
(
Double
alpha
){
List
<
Double
>
newVec
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
this
.
getNbre
();
i
++){
newVec
.
add
(
alpha
);
}
return
new
Vector
(
newVec
);
}
}
@Override
public
String
toString
()
{
...
...
This diff is collapsed.
Click to expand it.
src/test/java/ch/hepia/numeric/AppTest.java
+
7
−
0
View file @
af9d6d78
...
...
@@ -137,4 +137,11 @@ class VectorTest {
assertEquals
(
v
.
slice
(
4
,
2
),
Transposed
.
empty
());
assertEquals
(
v
.
removed
(
2
),
Transposed
.
of
(
1.0
,
2.0
,
4.0
,
5.0
));
}
// Vector V2 functions test :
@Test
void
vectorfillv2
()
{
assertEquals
(
Vector
.
fill
(
3
).
withValue
(
1.7
),
Vector
.
of
(
1.7
,
1.7
,
1.7
));
assertEquals
(
Vector
.
fill
(
4
).
withValue
(
1.5
),
Vector
.
of
(
1.5
,
1.5
,
1.5
,
1.5
));
assertEquals
(
Vector
.
fill
(
2
).
withValue
(
1.0
),
Vector
.
of
(
1.0
,
1.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