Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
456c722e
There was an error fetching the commit references. Please try again later.
Commit
456c722e
authored
5 years ago
by
Tomáš Oberhuber
Committed by
Tomáš Oberhuber
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixing Vector documentation.
parent
362727e5
No related branches found
No related tags found
1 merge request
!44
Tutorials
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Documentation/Examples/Containers/VectorExample.cpp
+14
-14
14 additions, 14 deletions
Documentation/Examples/Containers/VectorExample.cpp
src/TNL/Containers/Vector.h
+3
-1
3 additions, 1 deletion
src/TNL/Containers/Vector.h
with
17 additions
and
15 deletions
Documentation/Examples/Containers/VectorExample.cpp
+
14
−
14
View file @
456c722e
...
...
@@ -7,16 +7,15 @@ using namespace std;
int
main
()
{
Containers
::
Vector
<
int
>
vector1
;
vector1
.
setSize
(
5
);
vector1
.
setValue
(
0
);
cout
<<
"Does vector contain 1?"
<<
vector1
.
containsValue
(
1
)
<<
endl
;
cout
<<
"Does vector contain only zeros?"
<<
vector1
.
containsOnlyValue
(
0
)
<<
endl
;
Containers
::
Vector
<
int
>
vector1
(
5
);
vector1
=
0
;
cout
<<
"Does vector contain 1?"
<<
vector1
.
containsValue
(
1
)
<<
endl
;
cout
<<
"Does vector contain only zeros?"
<<
vector1
.
containsOnlyValue
(
0
)
<<
endl
;
Containers
::
Vector
<
int
>
vector2
(
3
);
vector2
.
setValue
(
1
)
;
vector2
.
swap
(
vector1
);
vector2
.
setElement
(
2
,
4
);
Containers
::
Vector
<
int
>
vector2
(
3
);
vector2
=
1
;
vector2
.
swap
(
vector1
);
vector2
.
setElement
(
2
,
4
);
cout
<<
"First vector:"
<<
vector1
.
getData
()
<<
endl
;
cout
<<
"Second vector:"
<<
vector2
.
getData
()
<<
endl
;
...
...
@@ -24,10 +23,11 @@ int main()
vector2
.
reset
();
cout
<<
"Second vector after reset:"
<<
vector2
.
getData
()
<<
endl
;
/*Containers::Vector<int> vect = {1, 2, -3, 3};
cout << "The smallest element is:" << vect.min() << endl;
cout << "The absolute biggest element is:" << vect.absMax() << endl;
cout << "Sum of all vector elements:" << vect.sum() << endl;
vect.scalarMultiplication(2);*/
Containers
::
Vector
<
int
>
vect
=
{
1
,
2
,
-
3
,
3
};
cout
<<
"The smallest element is:"
<<
min
(
vect
)
<<
endl
;
cout
<<
"The absolute biggest element is:"
<<
max
(
abs
(
vect
)
)
<<
endl
;
cout
<<
"Sum of all vector elements:"
<<
sum
(
vect
)
<<
endl
;
vect
*=
2.0
;
cout
<<
"Vector multiplied by 2:"
<<
vect
<<
endl
;
}
This diff is collapsed.
Click to expand it.
src/TNL/Containers/Vector.h
+
3
−
1
View file @
456c722e
...
...
@@ -32,7 +32,9 @@ namespace Containers {
* is selected with \ref Allocators::Default.
*
* \par Example
* \include VectorExample.cpp
* \include Containers/VectorExample.cpp
* \par Output
* \include VectorExample.out
*/
template
<
typename
Real
=
double
,
typename
Device
=
Devices
::
Host
,
...
...
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