Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F62064605
legacy_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
Fri, May 10, 16:56
Size
3 KB
Mime Type
text/x-c++
Expires
Sun, May 12, 16:56 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17428091
Attached To
rTAMAAS tamaas
legacy_types.hh
View Options
/**
* @file
* @section LICENSE
*
* Copyright (©) 2016-2020 EPFL (École Polytechnique Fédérale de Lausanne),
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __TYPES_HH__
#define __TYPES_HH__
/* -------------------------------------------------------------------------- */
#include "grid.hh"
#include "tamaas.hh"
#include <cstddef>
/* -------------------------------------------------------------------------- */
namespace
tamaas
{
namespace
legacy
{
template
<
typename
T
,
UInt
dim
>
class
Proxy
:
public
Grid
<
T
,
dim
>
{
public
:
/// Default constructor
Proxy
()
:
Grid
<
T
,
dim
>
()
{}
/// Copy constructor
Proxy
(
Proxy
&
o
)
:
Grid
<
T
,
dim
>
()
{
this
->
n
=
o
.
n
;
this
->
nb_components
=
o
.
nb_components
;
this
->
strides
=
o
.
strides
;
this
->
data
.
wrapMemory
(
o
.
getInternalData
(),
o
.
dataSize
());
}
/// Destructor
~
Proxy
()
override
=
default
;
public
:
/// Set pointer
void
setPointer
(
T
*
ptr
)
{
this
->
data
.
setData
(
ptr
);
}
/// Get increment
ptrdiff_t
increment
()
const
{
return
this
->
data
.
size
();
}
///
Proxy
&
operator
=
(
const
Proxy
&
o
)
{
this
->
copy
(
o
);
return
*
this
;
}
Proxy
&
operator
=
(
T
val
)
{
Grid
<
T
,
dim
>::
operator
=
(
val
);
return
*
this
;
}
template
<
typename
T1
>
Proxy
&
operator
=
(
const
Grid
<
T1
,
dim
>&
o
)
{
this
->
copy
(
o
);
return
*
this
;
}
template
<
typename
T1
>
void
copy
(
const
Grid
<
T1
,
dim
>&
o
)
{
Grid
<
T
,
dim
>::
copy
(
o
);
this
->
data
.
setWrapped
(
true
);
}
};
// 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
);
using
Proxy
<
T
,
1
>::
Proxy
;
~
VectorProxy
()
override
=
default
;
public
:
/// = operator
using
Proxy
<
T
,
1
>::
operator
=
;
/// 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
;
};
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
class
MatrixProxy
:
public
Proxy
<
T
,
2
>
{
public
:
/// Wrap on memory
MatrixProxy
(
T
*
mem
,
UInt
n
,
UInt
m
);
using
Proxy
<
T
,
2
>::
Proxy
;
~
MatrixProxy
()
override
=
default
;
public
:
/// = operator
using
Proxy
<
T
,
2
>::
operator
=
;
};
}
// namespace legacy
}
// namespace tamaas
#endif
// __TYPES_HH__
Event Timeline
Log In to Comment