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
b3d86f89
There was an error fetching the commit references. Please try again later.
Commit
b3d86f89
authored
5 years ago
by
Tomáš Oberhuber
Browse files
Options
Downloads
Patches
Plain Diff
Updating API of tridiagonal matrix.
parent
97888bf1
No related branches found
No related tags found
1 merge request
!48
Segments
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/TNL/Matrices/Tridiagonal.h
+114
-132
114 additions, 132 deletions
src/TNL/Matrices/Tridiagonal.h
src/TNL/Matrices/Tridiagonal.hpp
+252
-232
252 additions, 232 deletions
src/TNL/Matrices/Tridiagonal.hpp
with
366 additions
and
364 deletions
src/TNL/Matrices/Tridiagonal.h
+
114
−
132
View file @
b3d86f89
...
...
@@ -13,197 +13,179 @@
#include
<TNL/Matrices/Matrix.h>
#include
<TNL/Containers/Vector.h>
#include
<TNL/Matrices/TridiagonalRow.h>
#include
<TNL/Containers/Segments/Ellpack.h>
namespace
TNL
{
namespace
Matrices
{
namespace
Matrices
{
template
<
typename
Device
>
class
TridiagonalDeviceDependentCode
;
template
<
typename
Real
=
double
,
typename
Device
=
Devices
::
Host
,
typename
Index
=
int
>
class
Tridiagonal
:
public
Matrix
<
Real
,
Device
,
Index
>
typename
Index
=
int
,
bool
RowMajorOrder
=
std
::
is_same
<
Device
,
Devices
::
Host
>
::
value
,
typename
RealAllocator
=
typename
Allocators
::
Default
<
Device
>::
template
Allocator
<
Real
>
>
class
Tridiagonal
:
public
Matrix
<
Real
,
Device
,
Index
,
RealAllocator
>
{
private:
// convenient template alias for controlling the selection of copy-assignment operator
template
<
typename
Device2
>
using
Enabler
=
std
::
enable_if
<
!
std
::
is_same
<
Device2
,
Device
>::
value
>
;
private:
// convenient template alias for controlling the selection of copy-assignment operator
template
<
typename
Device2
>
using
Enabler
=
std
::
enable_if
<
!
std
::
is_same
<
Device2
,
Device
>::
value
>
;
// friend class will be needed for templated assignment operators
template
<
typename
Real2
,
typename
Device2
,
typename
Index2
>
friend
class
Tridiagonal
;
// friend class will be needed for templated assignment operators
template
<
typename
Real2
,
typename
Device2
,
typename
Index2
>
friend
class
Tridiagonal
;
public:
typedef
Real
RealType
;
typedef
Device
DeviceType
;
typedef
Index
IndexType
;
typedef
typename
Matrix
<
Real
,
Device
,
Index
>::
CompressedRowLengthsVector
CompressedRowLengthsVector
;
typedef
typename
Matrix
<
Real
,
Device
,
Index
>::
ConstCompressedRowLengthsVectorView
ConstCompressedRowLengthsVectorView
;
typedef
Matrix
<
Real
,
Device
,
Index
>
BaseType
;
typedef
TridiagonalRow
<
Real
,
Index
>
MatrixRow
;
public:
using
RealType
=
Real
;
using
DeviceType
=
Device
;
using
IndexType
=
Index
;
using
RealAllocatorType
=
RealAllocator
;
using
BaseType
=
Matrix
<
Real
,
Device
,
Index
,
RealAllocator
>
;
using
ValuesType
=
typename
BaseType
::
ValuesVector
;
using
ValuesViewType
=
typename
ValuesType
::
ViewType
;
//using ViewType = TridiagonalMatrixView< Real, Device, Index, RowMajorOrder >;
//using ConstViewType = TridiagonalMatrixView< typename std::add_const< Real >::type, Device, Index, RowMajorOrder >;
using
RowView
=
TridiagonalMatrixRowView
<
SegmentViewType
,
ValuesViewType
>
;
template
<
typename
_Real
=
Real
,
typename
_Device
=
Device
,
typename
_Index
=
Index
>
using
Self
=
Tridiagonal
<
_Real
,
_Device
,
_Index
>
;
Tridiagonal
();
template
<
typename
_Real
=
Real
,
typename
_Device
=
Device
,
typename
_Index
=
Index
>
using
Self
=
Tridiagonal
<
_Real
,
_Device
,
_Index
>
;
static
String
getSerializationType
();
Tridiagonal
();
virtual
String
getSerializationTypeVirtual
()
const
;
Tridiagonal
(
const
IndexType
rows
,
const
IndexType
columns
)
;
void
setDimensions
(
const
IndexType
rows
,
const
IndexType
columns
);
ViewType
getView
();
void
setCompressedRowLengths
(
ConstCompressedRowLengthsVectorView
rowLengths
)
;
ConstViewType
getConstView
()
const
;
IndexType
getRowLength
(
const
IndexType
row
)
const
;
static
String
getSerializationType
()
;
__cuda_callable__
IndexType
getRowLengthFast
(
const
IndexType
row
)
const
;
virtual
String
getSerializationTypeVirtual
()
const
;
IndexType
getMaxRowLength
()
const
;
void
setDimensions
(
const
IndexType
rows
,
const
IndexType
columns
);
template
<
typename
Real2
,
typename
Device2
,
typename
Index2
>
void
setLike
(
const
Tridiagonal
<
Real2
,
Device2
,
Index2
>&
m
);
void
setCompressedRowLengths
(
ConstCompressedRowLengthsVectorView
rowLengths
);
IndexType
getNumberOfMatrixElements
()
const
;
template
<
typename
Vector
>
void
getCompressedRowLengths
(
Vector
&
rowLengths
)
const
;
IndexType
getNumberOfNonzeroMatrixElements
()
const
;
[[
deprecated
]]
IndexType
getRowLength
(
const
IndexType
row
)
const
;
IndexType
getMaxRow
l
ength
()
const
;
IndexType
getMaxRow
L
ength
()
const
;
void
reset
();
template
<
typename
Real2
,
typename
Device2
,
typename
Index2
>
void
setLike
(
const
Tridiagonal
<
Real2
,
Device2
,
Index2
>&
m
);
template
<
typename
Real2
,
typename
Device2
,
typename
Index2
>
bool
operator
==
(
const
Tridiagonal
<
Real2
,
Device2
,
Index2
>&
matrix
)
const
;
IndexType
getNumberOfMatrixElements
()
const
;
template
<
typename
Real2
,
typename
Device2
,
typename
Index2
>
bool
operator
!=
(
const
Tridiagonal
<
Real2
,
Device2
,
Index2
>&
matrix
)
const
;
IndexType
getNumberOfNonzeroMatrixElements
()
const
;
void
setValue
(
const
RealType
&
v
)
;
IndexType
getMaxRowlength
()
const
;
__cuda_callable__
bool
setElementFast
(
const
IndexType
row
,
const
IndexType
column
,
const
RealType
&
value
);
void
reset
();
bool
setElement
(
const
IndexType
row
,
const
IndexType
column
,
const
RealType
&
value
);
template
<
typename
Real_
,
typename
Device_
,
typename
Index_
,
bool
RowMajorOrder_
>
bool
operator
==
(
const
Tridiagonal
<
Real_
,
Device_
,
Index_
,
RowMajorOrder_
>&
matrix
)
const
;
__cuda_callable__
bool
addElementFast
(
const
IndexType
row
,
const
IndexType
column
,
const
RealType
&
value
,
const
RealType
&
thisElementMultiplicator
=
1.0
);
template
<
typename
Real_
,
typename
Device_
,
typename
Index_
,
bool
RowMajorOrder_
>
bool
operator
!=
(
const
Tridiagonal
<
Real_
,
Device_
,
Index_
>&
matrix
)
const
;
bool
addElement
(
const
IndexType
row
,
const
IndexType
column
,
const
RealType
&
value
,
const
RealType
&
thisElementMultiplicator
=
1.0
);
void
setValue
(
const
RealType
&
v
);
__cuda_callable__
bool
setRowFast
(
const
IndexType
row
,
const
IndexType
*
columns
,
const
RealType
*
values
,
const
IndexType
elements
);
bool
setElement
(
const
IndexType
row
,
const
IndexType
column
,
const
RealType
&
value
);
bool
setRow
(
const
IndexType
row
,
const
IndexType
*
column
s
,
const
RealType
*
value
s
,
const
IndexType
elements
);
bool
addElement
(
const
IndexType
row
,
const
IndexType
column
,
const
RealType
&
value
,
const
RealType
&
thisElementMultiplicator
=
1.0
);
__cuda_callable__
bool
addRowFast
(
const
IndexType
row
,
const
IndexType
*
columns
,
const
RealType
*
values
,
const
IndexType
elements
,
const
RealType
&
thisRowMultiplicator
=
1.0
);
RealType
getElement
(
const
IndexType
row
,
const
IndexType
column
)
const
;
bool
addRow
(
const
IndexType
row
,
const
IndexType
*
columns
,
const
RealType
*
values
,
const
IndexType
elements
,
const
RealType
&
thisRowMultiplicator
=
1.0
);
template
<
typename
Fetch
,
typename
Reduce
,
typename
Keep
,
typename
FetchReal
>
void
rowsReduction
(
IndexType
first
,
IndexType
last
,
Fetch
&
fetch
,
Reduce
&
reduce
,
Keep
&
keep
,
const
FetchReal
&
zero
)
const
;
__cuda_callable__
RealType
getElementFast
(
const
IndexType
row
,
const
IndexType
column
)
const
;
template
<
typename
Fetch
,
typename
Reduce
,
typename
Keep
,
typename
FetchReal
>
void
allRowsReduction
(
Fetch
&
fetch
,
Reduce
&
reduce
,
Keep
&
keep
,
const
FetchReal
&
zero
)
const
;
RealType
getElement
(
const
IndexType
row
,
con
st
IndexType
colum
n
)
const
;
template
<
typename
Function
>
void
forRows
(
IndexType
fir
st
,
IndexType
last
,
Function
&
functio
n
)
const
;
__cuda_callable__
void
getRowFast
(
const
IndexType
row
,
IndexType
*
columns
,
RealType
*
values
)
const
;
template
<
typename
Function
>
void
forRows
(
IndexType
first
,
IndexType
last
,
Function
&
function
);
__cuda_callable__
MatrixRow
get
Row
(
const
IndexType
rowIndex
)
;
template
<
typename
Function
>
void
forAll
Row
s
(
Function
&
function
)
const
;
__cuda_callable__
const
MatrixRow
getRow
(
const
IndexType
rowIndex
)
const
;
template
<
typename
Function
>
void
forAllRows
(
Function
&
function
)
;
template
<
typename
Vector
>
__cuda_callable__
typename
Vector
::
RealType
rowVectorProduct
(
const
IndexType
row
,
const
Vector
&
vector
)
const
;
template
<
typename
Vector
>
__cuda_callable__
typename
Vector
::
RealType
rowVectorProduct
(
const
IndexType
row
,
const
Vector
&
vector
)
const
;
template
<
typename
InVector
,
typename
OutVector
>
void
vectorProduct
(
const
InVector
&
inVector
,
OutVector
&
outVector
)
const
;
template
<
typename
InVector
,
typename
OutVector
>
void
vectorProduct
(
const
InVector
&
inVector
,
OutVector
&
outVector
)
const
;
template
<
typename
Real2
,
typename
Index2
>
void
addMatrix
(
const
Tridiagonal
<
Real2
,
Device
,
Index2
>&
matrix
,
const
RealType
&
matrixMultiplicator
=
1.0
,
const
RealType
&
thisMatrixMultiplicator
=
1.0
);
template
<
typename
Real2
,
typename
Index2
>
void
addMatrix
(
const
Tridiagonal
<
Real2
,
Device
,
Index2
>&
matrix
,
const
RealType
&
matrixMultiplicator
=
1.0
,
const
RealType
&
thisMatrixMultiplicator
=
1.0
);
template
<
typename
Real2
,
typename
Index2
>
void
getTransposition
(
const
Tridiagonal
<
Real2
,
Device
,
Index2
>&
matrix
,
const
RealType
&
matrixMultiplicator
=
1.0
);
template
<
typename
Real2
,
typename
Index2
>
void
getTransposition
(
const
Tridiagonal
<
Real2
,
Device
,
Index2
>&
matrix
,
const
RealType
&
matrixMultiplicator
=
1.0
);
template
<
typename
Vector1
,
typename
Vector2
>
__cuda_callable__
void
performSORIteration
(
const
Vector1
&
b
,
const
IndexType
row
,
Vector2
&
x
,
const
RealType
&
omega
=
1.0
)
const
;
template
<
typename
Vector1
,
typename
Vector2
>
__cuda_callable__
void
performSORIteration
(
const
Vector1
&
b
,
const
IndexType
row
,
Vector2
&
x
,
const
RealType
&
omega
=
1.0
)
const
;
// copy assignment
Tridiagonal
&
operator
=
(
const
Tridiagonal
&
matrix
);
// copy assignment
Tridiagonal
&
operator
=
(
const
Tridiagonal
&
matrix
);
// cross-device copy assignment
template
<
typename
Real2
,
typename
Device2
,
typename
Index2
,
typename
=
typename
Enabler
<
Device2
>
::
type
>
Tridiagonal
&
operator
=
(
const
Tridiagonal
<
Real2
,
Device2
,
Index2
>&
matrix
);
// cross-device copy assignment
template
<
typename
Real2
,
typename
Device2
,
typename
Index2
,
typename
=
typename
Enabler
<
Device2
>
::
type
>
Tridiagonal
&
operator
=
(
const
Tridiagonal
<
Real2
,
Device2
,
Index2
>&
matrix
);
void
save
(
File
&
file
)
const
;
void
save
(
File
&
file
)
const
;
void
load
(
File
&
file
);
void
load
(
File
&
file
);
void
save
(
const
String
&
fileName
)
const
;
void
save
(
const
String
&
fileName
)
const
;
void
load
(
const
String
&
fileName
);
void
load
(
const
String
&
fileName
);
void
print
(
std
::
ostream
&
str
)
const
;
void
print
(
std
::
ostream
&
str
)
const
;
protected:
protected:
__cuda_callable__
IndexType
getElementIndex
(
const
IndexType
row
,
const
IndexType
column
)
const
;
__cuda_callable__
IndexType
getElementIndex
(
const
IndexType
row
,
const
IndexType
column
)
const
;
Containers
::
Vector
<
RealType
,
DeviceType
,
IndexType
>
values
;
Containers
::
Vector
<
RealType
,
DeviceType
,
IndexType
>
values
;
typedef
TridiagonalDeviceDependentCode
<
DeviceType
>
DeviceDependentCode
;
friend
class
TridiagonalDeviceDependentCode
<
DeviceType
>
;
typedef
TridiagonalDeviceDependentCode
<
DeviceType
>
DeviceDependentCode
;
friend
class
TridiagonalDeviceDependentCode
<
DeviceType
>
;
};
}
// namespace Matrices
}
// namespace TNL
#include
<TNL/Matrices/Tridiagonal
_impl
.h>
#include
<TNL/Matrices/Tridiagonal.h
pp
>
This diff is collapsed.
Click to expand it.
src/TNL/Matrices/Tridiagonal.hpp
+
252
−
232
View file @
b3d86f89
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