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
94bd5285
Commit
94bd5285
authored
5 years ago
by
fefe
Browse files
Options
Downloads
Patches
Plain Diff
Functions: Add,od,constructors,len
parent
dee54ffc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/ch/hepia/numeric/Vector.java
+16
-7
16 additions, 7 deletions
src/main/java/ch/hepia/numeric/Vector.java
with
16 additions
and
7 deletions
src/main/java/ch/hepia/numeric/Vector.java
+
16
−
7
View file @
94bd5285
package
ch.hepia.numeric
;
package
ch.hepia.numeric
;
import
java.util.List
;
import
java.util.List
;
import
java.util.ArrayList
;
import
java.util.function.DoubleFunction
;
import
java.util.function.DoubleFunction
;
import
java.util.function.Function
;
import
java.util.function.Function
;
final
public
class
Vector
{
final
public
class
Vector
{
private
List
<
Double
>
values
;
private
Vector
()
{}
private
Vector
()
{}
private
Vector
(
Double
...
elements
)
{
private
Vector
(
Double
...
elements
)
{
throw
new
UnsupportedOperationException
(
"This feature isn't implemented yet"
);
List
<
Double
>
vec
=
new
ArrayList
<>();
for
(
double
elem
:
elements
){
vec
.
add
(
elem
);}
this
.
values
=
vec
;
}
}
private
Vector
(
List
<
Double
>
elements
)
{
private
Vector
(
List
<
Double
>
elements
)
{
th
row
new
UnsupportedOperationException
(
"This feature isn't implemented yet"
)
;
th
is
.
values
=
elements
;
}
}
public
Transposed
t
()
{
public
Transposed
t
()
{
...
@@ -18,18 +23,22 @@ final public class Vector {
...
@@ -18,18 +23,22 @@ final public class Vector {
}
}
public
int
len
()
{
public
int
len
()
{
throw
new
UnsupportedOperationException
(
"This feature isn't implemented yet"
);
return
this
.
values
.
size
(
);
}
}
public
double
get
(
int
i
)
{
public
double
get
(
int
i
)
{
throw
new
UnsupportedOperationException
(
"This feature isn't implemented yet"
);
return
this
.
values
.
get
(
i
);
}
}
void
set
(
int
i
,
double
value
)
{
void
set
(
int
i
,
double
value
)
{
th
row
new
UnsupportedOperationException
(
"This feature isn't implemented yet"
);
th
is
.
values
.
set
(
i
,
value
);
}
}
public
Vector
add
(
Vector
that
)
{
public
Vector
add
(
Vector
that
)
{
throw
new
UnsupportedOperationException
(
"This feature isn't implemented yet"
);
List
<
Double
>
newVec
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
this
.
len
();
i
++){
newVec
.
add
(
this
.
get
(
i
)+
that
.
get
(
i
));
}
return
new
Vector
(
newVec
);
}
}
public
Vector
mul
(
double
m
)
{
public
Vector
mul
(
double
m
)
{
...
@@ -77,7 +86,7 @@ final public class Vector {
...
@@ -77,7 +86,7 @@ final public class Vector {
}
}
public
static
Vector
of
(
Double
...
elements
)
{
public
static
Vector
of
(
Double
...
elements
)
{
throw
new
UnsupportedOperationException
(
"This feature isn't implemented yet"
);
return
new
Vector
(
elements
);
}
}
public
static
Vector
of
(
List
<
Double
>
elements
)
{
public
static
Vector
of
(
List
<
Double
>
elements
)
{
...
...
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