Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Core Modules
dune-common
Commits
7921cdf3
Commit
7921cdf3
authored
12 years ago
by
Markus Blatt
Browse files
Options
Downloads
Plain Diff
Synced with trunk
[[Imported from SVN: r6981]]
parents
0eb6be6b
a734b931
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/common/fassign.hh
+29
-16
29 additions, 16 deletions
dune/common/fassign.hh
dune/common/test/fmatrixtest.cc
+3
-0
3 additions, 0 deletions
dune/common/test/fmatrixtest.cc
with
32 additions
and
16 deletions
dune/common/fassign.hh
+
29
−
16
View file @
7921cdf3
...
...
@@ -38,12 +38,11 @@ namespace Dune {
/**
* @brief Marker class for next row
*
* overload operator <<= for Fi
l
edMatrix assignment
* overload operator <<= for Fie
l
dMatrix assignment
*/
struct
NextRow
{
explicit
NextRow
(
int
)
{};
}
nextRow
(
0
);
}
// end empty namespace
/**
...
...
@@ -149,22 +148,22 @@ namespace Dune {
}
/**
* @brief f
vector
assignment operator
* @brief f
matrix
assignment operator
*
* overload operator <<= for f
vector
assignment from Dune::Zero
* overload operator <<= for f
matrix
assignment from Dune::Zero
*
* after including fassing.hh you can easily assign data to a Field
Vector
* after including fassing.hh you can easily assign data to a Field
Matrix
* using
*
* @code
* Field
Vector
<double,
4
> x; x <<= 1.0, 4.0, 10.0, 11.0;
* Field
Matrix
<double,
2,2
> x; x <<= 1.0, 4.0,
nextRow,
10.0, 11.0;
* @endcode
*
* The operator checks that the whole
vector
is initalized.
* In case you know that all following entries will be zero padded, you can use
* The operator checks that the whole
matrix
is initalized.
* In case you know that all following entries
of a row
will be zero padded, you can use
*
* @code
* Field
Vector
<double, 4
0
> x; x <<= 1.0,
4.0
, 10.0, 11.0
, zero
;
* Field
Matrix
<double, 4
, 4
> x; x <<= 1.0,
zero, nextRow
, 10.0, 11.0;
* @endcode
*
*/
...
...
@@ -176,22 +175,27 @@ namespace Dune {
int
c
;
int
r
;
bool
temporary
;
bool
thrown
;
void
end_row
()
{
if
(
!
temporary
&&
c
!=
m
)
if
(
!
temporary
&&
c
!=
m
&&
!
thrown
)
{
thrown
=
true
;
DUNE_THROW
(
MathError
,
"Trying to assign "
<<
c
<<
" entries to a FieldMatrix row of size "
<<
m
);
}
c
=
0
;
}
public
:
/*! @brief Copy Constructor */
fmatrix_assigner
(
fmatrix_assigner
&
a
)
:
A
(
a
.
A
),
c
(
a
.
c
),
r
(
a
.
r
),
temporary
(
false
)
fmatrix_assigner
(
fmatrix_assigner
&
a
)
:
A
(
a
.
A
),
c
(
a
.
c
),
r
(
a
.
r
),
temporary
(
false
)
,
thrown
(
a
.
thrown
)
{}
/*! @brief Constructor from matrix and temporary flag
\param _A matrix which should be initialized
\param t bool indicating, that this is a temporary object (see ~fmatrix_assigner)
*/
fmatrix_assigner
(
FieldMatrix
<
T
,
n
,
m
>
&
_A
,
bool
t
)
:
A
(
_A
),
c
(
0
),
r
(
0
),
temporary
(
t
)
fmatrix_assigner
(
FieldMatrix
<
T
,
n
,
m
>
&
_A
,
bool
t
)
:
A
(
_A
),
c
(
0
),
r
(
0
),
temporary
(
t
),
thrown
(
false
)
{};
/*! @brief Destructor
checks for complete initialization of the matrix.
...
...
@@ -200,13 +204,21 @@ namespace Dune {
~
fmatrix_assigner
()
{
end_row
();
if
(
!
temporary
&&
r
!=
n
-
1
)
if
(
!
temporary
&&
r
!=
n
-
1
&&
!
thrown
)
{
thrown
=
true
;
DUNE_THROW
(
MathError
,
"Trying to assign "
<<
r
<<
" rows to a FieldMatrix of size "
<<
n
<<
" x "
<<
m
);
}
}
/*! @brief append data to this matrix */
fmatrix_assigner
&
append
(
const
T
&
t
)
{
// Check whether we have passed the last row
if
(
r
>=
m
)
{
thrown
=
true
;
DUNE_THROW
(
MathError
,
"Trying to assign more than "
<<
m
<<
" rows to a FieldMatrix of size "
<<
n
<<
" x "
<<
m
);
}
A
[
r
][
c
++
]
=
t
;
return
*
this
;
}
...
...
@@ -217,7 +229,7 @@ namespace Dune {
while
(
c
!=
m
)
A
[
r
][
c
++
]
=
0
;
return
*
this
;
}
/*! @brief
append zeros to
th
is
matrix
/*! @brief
move to next row of
th
e
matrix
*/
fmatrix_assigner
&
append
(
NextRow
nr
)
{
...
...
@@ -243,7 +255,8 @@ namespace Dune {
}
/*! @brief append zeros to this matrix
the overloaded comma operator is used to stop the assign of values
to the matrix, all remaining entries are assigned 0.
to the current row, it will be checked whether all entries have been
assigned values.
*/
fmatrix_assigner
&
operator
,
(
NextRow
nr
)
{
...
...
@@ -264,7 +277,7 @@ namespace Dune {
}
/**
* @brief
f
Fi
l
eMatrix assignment operator
* @brief Fie
ld
Matrix assignment operator
*
* overload operator <<= for FieldMatrix row assignment from Dune::Zero
*/
...
...
This diff is collapsed.
Click to expand it.
dune/common/test/fmatrixtest.cc
+
3
−
0
View file @
7921cdf3
...
...
@@ -3,7 +3,10 @@
#ifdef HAVE_CONFIG_H
#include
"config.h"
#endif
// Activate checking.
#ifndef DUNE_ISTL_WITH_CHECKING
#define DUNE_ISTL_WITH_CHECKING
#endif
#include
<dune/common/fmatrix.hh>
#include
<dune/common/fassign.hh>
#include
<dune/common/classname.hh>
...
...
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