Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79858217
types.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Aug 28, 15:38
Size
2 KB
Mime Type
text/x-c++
Expires
Fri, Aug 30, 15:38 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20246447
Attached To
rTAMAAS tamaas
types.hh
View Options
/**
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2016 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __TYPES_HH__
#define __TYPES_HH__
/* -------------------------------------------------------------------------- */
#include "tamaas.hh"
#include "grid.hh"
#include <cstddef>
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
template
<
typename
T
,
UInt
dim
>
class
Proxy
:
public
Grid
<
T
,
dim
>
{
public
:
/// Default constructor
Proxy
()
:
Grid
<
T
,
dim
>
()
{}
/// Copy constructor
Proxy
(
Proxy
&
p
)
:
Grid
<
T
,
dim
>
()
{
if
(
p
.
n
!=
this
->
n
)
std
::
copy
(
p
.
n
,
p
.
n
+
dim
,
this
->
n
);
this
->
nb_components
=
p
.
nb_components
;
this
->
data
.
wrapMemory
(
p
.
getInternalData
(),
p
.
dataSize
());
}
/// Destructor
virtual
~
Proxy
()
{}
public
:
/// Set pointer
void
setPointer
(
T
*
ptr
)
{
this
->
data
.
setPtr
(
ptr
);}
/// Get increment
ptrdiff_t
increment
()
const
{
return
this
->
data
.
size
();}
};
// Forward declarations
template
<
typename
T
>
class
MatrixProxy
;
template
<
typename
T
>
class
VectorProxy
:
public
Proxy
<
T
,
1
>
{
public
:
/// Wrap on memory
VectorProxy
(
T
*
mem
,
UInt
n
);
/// Copy constructor
VectorProxy
(
VectorProxy
&
v
)
:
Proxy
<
T
,
1
>
(
v
)
{}
/// Destructor
virtual
~
VectorProxy
();
public
:
/// Access
const
T
&
operator
()(
UInt
i
)
const
;
/// Access (non-const)
T
&
operator
()(
UInt
i
);
/// Matrix-vector multiplication
void
mul
(
const
MatrixProxy
<
T
>
&
mat
,
const
VectorProxy
<
T
>
&
vec
);
/// Dot product
T
dot
(
const
VectorProxy
<
T
>
&
vec
);
/// L2 norm
T
l2norm
()
const
;
/// = operator
using
Grid
<
T
,
1
>::
operator
=
;
};
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
class
MatrixProxy
:
public
Proxy
<
T
,
2
>
{
public
:
/// Wrap on memory
MatrixProxy
(
T
*
mem
,
UInt
n
,
UInt
m
);
/// Copy constructor
MatrixProxy
(
MatrixProxy
&
v
)
:
Proxy
<
T
,
2
>
(
v
)
{}
/// Destructor
virtual
~
MatrixProxy
();
public
:
/// Access
const
T
&
operator
()(
UInt
i
,
UInt
j
)
const
;
/// Access (non-const)
T
&
operator
()(
UInt
i
,
UInt
j
);
};
__END_TAMAAS__
#endif
// __TYPES_HH__
Event Timeline
Log In to Comment