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
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Timo Koch
dune-common
Commits
ccf26b4b
Commit
ccf26b4b
authored
20 years ago
by
Peter Bastian
Browse files
Options
Downloads
Patches
Plain Diff
A little example for the curios. Its just testing
[[Imported from SVN: r771]]
parent
3beb36dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
istl/bvector.hh
+3
-3
3 additions, 3 deletions
istl/bvector.hh
istl/example.cc
+133
-0
133 additions, 0 deletions
istl/example.cc
istl/fvector.hh
+3
-3
3 additions, 3 deletions
istl/fvector.hh
istl/istl.hh
+74
-0
74 additions, 0 deletions
istl/istl.hh
istl/vbvector.hh
+3
-3
3 additions, 3 deletions
istl/vbvector.hh
with
216 additions
and
9 deletions
istl/bvector.hh
+
3
−
3
View file @
ccf26b4b
...
...
@@ -8,7 +8,7 @@
#include
"../common/exceptions.hh"
#include
"
spmv
.hh"
#include
"
istl
.hh"
/*! \file __FILE__
...
...
@@ -19,8 +19,8 @@
namespace
Dune
{
/** @defgroup
SPMV Dune Sparse Matrix Vector
Template
s
@addtogroup
SPMV
/** @defgroup
ISTL Iterative Solvers
Template
Library
@addtogroup
ISTL
@{
*/
...
...
This diff is collapsed.
Click to expand it.
istl/example.cc
0 → 100644
+
133
−
0
View file @
ccf26b4b
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// start with including some headers
#include
<iostream>
// for input/output to shell
#include
<fstream>
// for input/output to files
#include
<vector>
// STL vector class
#include
<complex>
#include
<math.h>
// Yes, we do some math here
#include
<stdio.h>
// There is nothing better than sprintf
#include
<sys/times.h>
// for timing measurements
#include
"fvector.hh"
#include
"bvector.hh"
#include
"vbvector.hh"
class
Timer
{
public:
Timer
()
{
struct
tms
buf
;
cstart
=
times
(
&
buf
);
}
void
start
()
{
struct
tms
buf
;
cstart
=
times
(
&
buf
);
}
double
stop
()
{
struct
tms
buf
;
cend
=
times
(
&
buf
);
return
((
double
)(
cend
-
cstart
))
/
100.0
;
}
private
:
clock_t
cstart
,
cend
;
};
int
main
(
int
argc
,
char
**
argv
)
{
Dune
::
FieldVector
<
std
::
complex
<
double
>
,
7
>
v
;
v
=
std
::
complex
<
double
>
(
1.0
,
2.0
);
std
::
cout
<<
" |v|1="
<<
v
.
one_norm
()
<<
" |v|1real="
<<
v
.
one_norm_real
()
<<
" |v|2="
<<
v
.
two_norm
()
<<
" |v|inf="
<<
v
.
infinity_norm
()
<<
" |v|infreal="
<<
v
.
infinity_norm_real
()
<<
std
::
endl
;
std
::
cout
<<
" v*v="
<<
v
*
v
<<
std
::
endl
;
typedef
Dune
::
FieldVector
<
double
,
1
>
R1
;
typedef
Dune
::
FieldVector
<
double
,
2
>
R2
;
typedef
Dune
::
FieldVector
<
double
,
6
>
R6
;
typedef
Dune
::
FieldVector
<
double
,
10
>
R10
;
typedef
Dune
::
FieldVector
<
double
,
20
>
R20
;
typedef
Dune
::
FieldVector
<
double
,
40
>
R40
;
typedef
Dune
::
FieldVector
<
double
,
50
>
R50
;
typedef
Dune
::
FieldVector
<
double
,
80
>
R80
;
//const int n=1024*1024*32;
const
int
n
=
480
;
Dune
::
BlockVector
<
R1
>
x
(
n
),
y
(
n
);
x
=
0.0
;
y
=
5.3435E-6
;
Timer
watch
;
double
t
;
int
i
;
for
(
i
=
1
;
i
<
1000000000
;
i
*=
2
)
{
watch
.
start
();
for
(
int
j
=
0
;
j
<
i
;
++
j
)
x
.
axpy
(
1.001
,
y
);
t
=
watch
.
stop
();
if
(
t
>
1.0
)
break
;
}
std
::
cout
<<
"axpy:"
<<
" n="
<<
x
.
dim
()
<<
" i="
<<
i
<<
" t="
<<
t
<<
" mflop="
<<
2.0
*
x
.
dim
()
*
((
double
)
i
)
/
t
/
1E6
<<
std
::
endl
;
x
=
1.234E-3
;
y
=
4.938E-1
;
double
sum
=
0
;
for
(
i
=
1
;
i
<
1000000000
;
i
*=
2
)
{
watch
.
start
();
sum
=
0
;
for
(
int
j
=
0
;
j
<
i
;
++
j
)
sum
+=
x
*
y
;
t
=
watch
.
stop
();
if
(
t
>
1.0
)
break
;
}
std
::
cout
<<
" dot:"
<<
" n="
<<
x
.
dim
()
<<
" i="
<<
i
<<
" t="
<<
t
<<
" mflop="
<<
2.0
*
x
.
dim
()
*
((
double
)
i
)
/
t
/
1E6
<<
" sum="
<<
sum
<<
std
::
endl
;
try
{
typedef
Dune
::
VariableBlockVector
<
R1
>
VBV
;
VBV
w
(
20
);
for
(
VBV
::
CreateIterator
i
=
w
.
createbegin
();
i
!=
w
.
createend
();
++
i
)
i
.
setblocksize
(
i
.
blockindex
()
+
1
);
w
=
1.0
;
}
catch
(
Dune
::
ISTLError
&
error
)
{
std
::
cout
<<
error
<<
std
::
endl
;
}
return
0
;
}
This diff is collapsed.
Click to expand it.
istl/fvector.hh
+
3
−
3
View file @
ccf26b4b
...
...
@@ -8,7 +8,7 @@
#include
"../common/exceptions.hh"
#include
"
spmv
.hh"
#include
"
istl
.hh"
/*! \file __FILE__
...
...
@@ -18,8 +18,8 @@
namespace
Dune
{
/** @defgroup
SPMV Dune Sparse Matrix Vector
Template
s
@addtogroup
SPMV
/** @defgroup
ISTL Iterative Solvers
Template
Library
@addtogroup
ISTL
@{
*/
...
...
This diff is collapsed.
Click to expand it.
istl/istl.hh
0 → 100644
+
74
−
0
View file @
ccf26b4b
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef __DUNE_ISTL_HH__
#define __DUNE_ISTL_HH__
#include
<stdlib.h>
/** @defgroup ISTL Dune Sparse Matrix Vector Templates
The SPMV module defines a set of classes for sparse
matrices and vectors with the following features:
- They are efficient (including access to single elements)
- They provide a recursive block structure for a flexible
construction of iterative linear solvers
- They are very flexible
*/
namespace
Dune
{
/** @defgroup ISTL Iterative Solvers Template Library
@addtogroup ISTL
@{
*/
/** The default allocator for the sparse matrix vector classes:
- uses malloc and free
- member templates for type safety to the outside
- is a singleton
- illustrates state handling through counter
- throws std::bad_alloc just as new does
*/
class
SPMV_Allocator
{
// uses standard malloc and free
public:
//! allocate array of nmemb objects of type T
template
<
class
T
>
static
T
*
malloc
(
size_t
nmemb
)
{
T
*
p
=
static_cast
<
T
*>
(
std
::
malloc
(
nmemb
*
sizeof
(
T
)));
if
(
p
==
NULL
)
throw
std
::
bad_alloc
();
count
++
;
return
p
;
}
//! release memory previously allocated with malloc member
template
<
class
T
>
static
void
free
(
T
*
p
)
{
std
::
free
(
p
);
count
--
;
}
//! return number of allocated objects
unsigned
int
nobjects
()
{
return
count
;
}
private
:
// just to demonstrate some state information
static
unsigned
int
count
;
};
unsigned
int
SPMV_Allocator
::
count
=
0
;
/** @} end documentation */
}
// end namespace
#endif
This diff is collapsed.
Click to expand it.
istl/vbvector.hh
+
3
−
3
View file @
ccf26b4b
...
...
@@ -8,7 +8,7 @@
#include
"../common/exceptions.hh"
#include
"
spmv
.hh"
#include
"
istl
.hh"
#include
"bvector.hh"
/*! \file __FILE__
...
...
@@ -20,8 +20,8 @@
namespace
Dune
{
/** @defgroup
SPMV Dune Sparse Matrix Vector
Template
s
@addtogroup
SPMV
/** @defgroup
ISTL Iterative Solvers
Template
Library
@addtogroup
ISTL
@{
*/
...
...
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