Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88757112
surface_complex.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
Sun, Oct 20, 13:11
Size
3 KB
Mime Type
text/x-c++
Expires
Tue, Oct 22, 13:11 (1 d, 15 h)
Engine
blob
Format
Raw Data
Handle
21816675
Attached To
rTAMAAS tamaas
surface_complex.hh
View Options
#ifndef SURFACE_COMPLEX_H
#define SURFACE_COMPLEX_H
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
class
SurfaceComplex
:
public
Map2dSquare
<
std
::
complex
<
T
>
>
{
public
:
SurfaceComplex
(
UInt
a
,
Real
L
)
:
Map2dSquare
<
std
::
complex
<
T
>
>
(
a
,
L
){}
SurfaceComplex
(
Surface
<
T
>
&
s
);
SurfaceComplex
<
T
>
&
operator
=
(
const
Surface
<
T
>
&
s
);
SurfaceComplex
<
T
>
&
operator
=
(
const
SurfaceComplex
<
T
>
&
s
);
//! make a surface real by taking norm as real part and imaginary 0
void
makeItRealBySquare
();
//! make it real by summing the imaginary and real parts
void
makeItRealBySum
();
//! make a surface real by taking norm as real part and imaginary 0
void
makeItRealByAbs
();
//! get real part
Surface
<
T
>
real
()
const
;
//! get imaginary part
Surface
<
T
>
imag
()
const
;
// set all the members of the map to a given value
using
Map2d
<
std
::
complex
<
T
>
>::
operator
=
;
};
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
SurfaceComplex
<
T
>
&
SurfaceComplex
<
T
>::
operator
=
(
const
Surface
<
T
>
&
s
){
this
->
setGridSize
(
s
.
size
());
UInt
size
=
s
.
size
()
*
s
.
size
();
for
(
UInt
i
=
0
;
i
<
size
;
i
++
)
{
this
->
at
(
i
)
=
s
(
i
);
}
return
*
this
;
}
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
SurfaceComplex
<
T
>
&
SurfaceComplex
<
T
>::
operator
=
(
const
SurfaceComplex
<
T
>
&
s
){
this
->
setGridSize
(
s
.
size
());
UInt
size
=
s
.
size
()
*
s
.
size
();
for
(
UInt
i
=
0
;
i
<
size
;
i
++
)
{
this
->
at
(
i
)
=
s
(
i
);
}
return
*
this
;
}
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
Surface
<
T
>
SurfaceComplex
<
T
>::
real
()
const
{
Surface
<
T
>
res
(
this
->
size
(),
this
->
getL
());
UInt
n
=
this
->
size
();
for
(
UInt
i
=
0
;
i
<
n
;
++
i
)
for
(
UInt
j
=
0
;
j
<
n
;
++
j
){
res
(
i
,
j
)
=
this
->
at
(
i
,
j
).
real
();
}
return
res
;
}
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
Surface
<
T
>
SurfaceComplex
<
T
>::
imag
()
const
{
Surface
<
T
>
res
(
this
->
size
(),
this
->
getL
());
UInt
n
=
this
->
size
();
for
(
UInt
i
=
0
;
i
<
n
;
++
i
)
for
(
UInt
j
=
0
;
j
<
n
;
++
j
){
res
(
i
,
j
)
=
this
->
at
(
i
,
j
).
imag
();
}
return
res
;
}
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
void
SurfaceComplex
<
T
>::
makeItRealBySquare
(){
UInt
n
=
this
->
size
();
for
(
UInt
i
=
0
;
i
<
n
;
++
i
)
for
(
UInt
j
=
0
;
j
<
n
;
++
j
){
Real
norm
=
std
::
norm
(
this
->
at
(
i
,
j
));
this
->
at
(
i
,
j
)
=
norm
;
}
}
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
void
SurfaceComplex
<
T
>::
makeItRealByAbs
(){
UInt
n
=
this
->
size
();
for
(
UInt
i
=
0
;
i
<
n
;
++
i
)
for
(
UInt
j
=
0
;
j
<
n
;
++
j
){
Real
abs
=
std
::
abs
(
this
->
at
(
i
,
j
));
this
->
at
(
i
,
j
)
=
abs
;
}
}
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
void
SurfaceComplex
<
T
>::
makeItRealBySum
(){
UInt
n
=
this
->
size
();
for
(
UInt
i
=
0
;
i
<
n
*
n
;
++
i
){
this
->
at
(
i
)
=
this
->
at
(
i
).
real
()
+
this
->
at
(
i
).
imag
();
}
}
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
SurfaceComplex
<
T
>::
SurfaceComplex
(
Surface
<
T
>
&
surface
)
:
Map2dSquare
<
std
::
complex
<
T
>
>
(
surface
.
size
(),
surface
.
getL
()){
UInt
n
=
this
->
size
();
for
(
UInt
i
=
0
;
i
<
n
*
n
;
i
++
)
{
this
->
at
(
i
)
=
surface
(
i
);
}
}
/* -------------------------------------------------------------------------- */
#endif
/* SURFACE_COMPLEX_H */
Event Timeline
Log In to Comment