Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-matrix-vector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
agnumpde
dune-matrix-vector
Commits
4f2f7660
Commit
4f2f7660
authored
10 years ago
by
Max Kahnt
Browse files
Options
Downloads
Patches
Plain Diff
Use SingleNonZeroRowMatrix implementation that was in ComponentwiseMatrixMap.
parent
af9869d7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/matrix-vector/singlenonzerorowmatrix.hh
+69
-41
69 additions, 41 deletions
dune/matrix-vector/singlenonzerorowmatrix.hh
with
69 additions
and
41 deletions
dune/matrix-vector/singlenonzerorowmatrix.hh
+
69
−
41
View file @
4f2f7660
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
#include
<dune/fufem/arithmetic.hh>
#include
<dune/fufem/arithmetic.hh>
#include
<dune/fufem/indexedsliceiterator.hh>
#include
<dune/fufem/indexedsliceiterator.hh>
/**
/**
* \brief A static matrix that has only a single nonzero row
* \brief A static matrix that has only a single nonzero row
*
*
...
@@ -17,39 +16,81 @@
...
@@ -17,39 +16,81 @@
* all entries accordingly. So it will not reduce memory
* all entries accordingly. So it will not reduce memory
* requirements but allows to implement methods more efficiently.
* requirements but allows to implement methods more efficiently.
*/
*/
template
<
class
K
,
int
ROWS
,
int
COLS
>
template
<
class
K
,
int
ROWS
,
int
COLS
>
//TODO allow to set storage type as in singlenonzerocolumnmatrix. Update docu accordingly.
class
SingleNonZeroRowMatrix
:
class
SingleNonZeroRowMatrix
public
Dune
::
FieldMatrix
<
K
,
ROWS
,
COLS
>
{
{
typedef
typename
Dune
::
FieldMatrix
<
K
,
ROWS
,
COLS
>
Base
;
public:
typedef
typename
Dune
::
FieldMatrix
<
K
,
1
,
COLS
>
SingleRowMatrix
;
protected:
class
RowProxy
{
public:
typedef
std
::
size_t
size_type
;
typedef
typename
SingleRowMatrix
::
ConstColIterator
ConstIterator
;
typedef
ConstIterator
const_iterator
;
RowProxy
(
const
SingleRowMatrix
*
nzRow
,
size_type
rowIndex
,
size_type
nzRowIndex
)
:
nzRow_
(
nzRow
),
isNonZero_
(
rowIndex
==
nzRowIndex
)
{}
ConstIterator
begin
()
const
{
if
(
isNonZero_
)
return
(
*
nzRow_
)[
0
].
begin
();
else
return
(
*
nzRow_
)[
0
].
end
();
}
ConstIterator
end
()
const
{
return
(
*
nzRow_
)[
0
].
end
();
}
protected
:
const
SingleRowMatrix
*
nzRow_
;
bool
isNonZero_
;
};
public
:
public
:
enum
{
rows
=
ROWS
,
cols
=
COLS
};
typedef
typename
Dune
::
FieldMatrix
<
K
,
1
,
Base
::
cols
>
SingleRowMatrix
;
typedef
RowProxy
row_type
;
typedef
row_type
const_row_reference
;
typedef
typename
std
::
size_t
size_type
;
typedef
typename
RowProxy
::
ConstIterator
ConstColIterator
;
/**
/**
* \brief Create from single row matrix and row index
* \brief Create from single row matrix and row index
*/
*/
SingleNonZeroRowMatrix
(
const
SingleRowMatrix
&
c
,
int
row
)
:
SingleNonZeroRowMatrix
(
const
SingleRowMatrix
&
r
,
size_type
nzRowIndex
)
:
Base
(
0.0
),
nzRow_
(
r
),
row_
(
row
)
nzRowIndex_
(
nzRowIndex
)
{}
size_type
N
()
const
{
return
ROWS
;
}
size_type
M
()
const
{
{
for
(
int
i
=
0
;
i
<
Base
::
cols
;
++
i
)
return
COLS
;
(
*
this
)[
row_
][
i
]
=
c
[
0
][
i
];
}
}
template
<
class
X
,
class
Y
>
template
<
class
X
,
class
Y
>
void
umv
(
const
X
&
x
,
Y
&
y
)
const
void
umv
(
const
X
&
x
,
Y
&
y
)
const
{
{
for
(
int
i
=
0
;
i
<
Base
::
cols
;
++
i
)
for
(
size_type
i
=
0
;
i
<
M
()
;
++
i
)
y
[
row_
]
+=
(
*
this
)[
r
ow_
][
i
]
*
x
[
i
];
y
[
nzRowIndex_
]
+=
nzR
ow_
[
0
][
i
]
*
x
[
i
];
}
}
template
<
class
X
,
class
Y
>
template
<
class
X
,
class
Y
>
void
umtv
(
const
X
&
x
,
Y
&
y
)
const
void
umtv
(
const
X
&
x
,
Y
&
y
)
const
{
{
for
(
int
i
=
0
;
i
<
Base
::
cols
;
++
i
)
for
(
size_type
i
=
0
;
i
<
N
()
;
++
i
)
y
[
i
]
=
(
*
this
)[
r
ow_
][
i
]
*
x
[
row
_
];
y
[
i
]
=
nzR
ow_
[
0
][
i
]
*
x
[
nzRowIndex
_
];
}
}
template
<
class
X
,
class
Y
>
template
<
class
X
,
class
Y
>
...
@@ -59,19 +100,19 @@ public:
...
@@ -59,19 +100,19 @@ public:
umtv
(
x
,
y
);
umtv
(
x
,
y
);
}
}
int
nonZeroR
owIndex
(
)
const
const_row_reference
operator
[]
(
size_type
r
owIndex
)
const
{
{
return
row_
;
return
const_row_reference
(
&
nzRow_
,
rowIndex
,
nzRowIndex_
)
;
}
}
const
Base
::
row
_type
&
nonZeroRow
()
const
size
_type
nonZeroRow
Index
()
const
{
{
return
(
*
this
)[
row_
]
;
return
nzRowIndex_
;
}
}
protected
:
protected
:
SingleRowMatrix
nzRow_
;
const
int
row
_
;
const
size_type
nzRowIndex
_
;
};
};
...
@@ -81,27 +122,14 @@ namespace Arithmetic
...
@@ -81,27 +122,14 @@ namespace Arithmetic
template
<
class
K
,
int
ROWS
,
int
COLS
>
template
<
class
K
,
int
ROWS
,
int
COLS
>
struct
MatrixTraits
<
SingleNonZeroRowMatrix
<
K
,
ROWS
,
COLS
>
>
struct
MatrixTraits
<
SingleNonZeroRowMatrix
<
K
,
ROWS
,
COLS
>
>
{
{
enum
{
isMatrix
=
true
};
enum
{
isMatrix
=
true
};
enum
{
rows
=
ROWS
};
enum
{
isDense
=
false
};
enum
{
cols
=
COLS
};
enum
{
sizeIsStatic
=
true
};
//TODO only one of these should be used
typedef
typename
SingleNonZeroRowMatrix
<
K
,
ROWS
,
COLS
>::
row_type
::
ConstColIterator
ConstColIterator
;
enum
{
hasStaticSize
=
true
};
//TODO only one of these should be used
enum
{
rows
=
ROWS
};
static
ConstColIterator
rowBegin
(
const
typename
SingleNonZeroRowMatrix
<
K
,
ROWS
,
COLS
>::
row_type
&
m
,
int
row
)
enum
{
cols
=
COLS
};
{
if
(
row
==
m
.
nonZeroRowIndex
())
return
m
.
nonZeroRow
().
begin
();
else
return
m
.
nonZeroRow
().
end
();
}
static
ConstColIterator
rowEnd
(
const
typename
SingleNonZeroRowMatrix
<
K
,
ROWS
,
COLS
>::
row_type
&
m
,
int
row
)
{
return
m
.
nonZeroRow
().
end
();
}
};
};
}
};
#endif
#endif
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