Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Simon Perkins
ducc
Commits
4af2d1d2
Commit
4af2d1d2
authored
Jan 03, 2020
by
Martin Reinecke
Browse files
unify macros
parent
e0d1c40c
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
src/mr_util/cmplx.h
0 → 100644
View file @
4af2d1d2
/*
* This file is part of the MR utility library.
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This code 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this code; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Copyright (C) 2019 Max-Planck-Society
Author: Martin Reinecke */
#ifndef MRUTIL_CMPLX_H
#define MRUTIL_CMPLX_H
namespace
mr
{
template
<
typename
T
>
struct
Cmplx
{
T
r
,
i
;
Cmplx
()
{}
Cmplx
(
T
r_
,
T
i_
)
:
r
(
r_
),
i
(
i_
)
{}
void
Set
(
T
r_
,
T
i_
)
{
r
=
r_
;
i
=
i_
;
}
void
Set
(
T
r_
)
{
r
=
r_
;
i
=
T
(
0
);
}
void
Split
(
T
&
r_
,
T
&
i_
)
const
{
r_
=
r
;
i_
=
i
;
}
void
SplitConj
(
T
&
r_
,
T
&
i_
)
const
{
r_
=
r
;
i_
=-
i
;
}
Cmplx
&
operator
+=
(
const
Cmplx
&
other
)
{
r
+=
other
.
r
;
i
+=
other
.
i
;
return
*
this
;
}
template
<
typename
T2
>
Cmplx
&
operator
*=
(
T2
other
)
{
r
*=
other
;
i
*=
other
;
return
*
this
;
}
template
<
typename
T2
>
Cmplx
&
operator
*=
(
const
Cmplx
<
T2
>
&
other
)
{
T
tmp
=
r
*
other
.
r
-
i
*
other
.
i
;
i
=
r
*
other
.
i
+
i
*
other
.
r
;
r
=
tmp
;
return
*
this
;
}
template
<
typename
T2
>
Cmplx
&
operator
+=
(
const
Cmplx
<
T2
>
&
other
)
{
r
+=
other
.
r
;
i
+=
other
.
i
;
return
*
this
;
}
template
<
typename
T2
>
Cmplx
&
operator
-=
(
const
Cmplx
<
T2
>
&
other
)
{
r
-=
other
.
r
;
i
-=
other
.
i
;
return
*
this
;
}
template
<
typename
T2
>
auto
operator
*
(
const
T2
&
other
)
const
->
Cmplx
<
decltype
(
r
*
other
)
>
{
return
{
r
*
other
,
i
*
other
};
}
template
<
typename
T2
>
auto
operator
+
(
const
Cmplx
<
T2
>
&
other
)
const
->
Cmplx
<
decltype
(
r
+
other
.
r
)
>
{
return
{
r
+
other
.
r
,
i
+
other
.
i
};
}
template
<
typename
T2
>
auto
operator
-
(
const
Cmplx
<
T2
>
&
other
)
const
->
Cmplx
<
decltype
(
r
+
other
.
r
)
>
{
return
{
r
-
other
.
r
,
i
-
other
.
i
};
}
template
<
typename
T2
>
auto
operator
*
(
const
Cmplx
<
T2
>
&
other
)
const
->
Cmplx
<
decltype
(
r
+
other
.
r
)
>
{
return
{
r
*
other
.
r
-
i
*
other
.
i
,
r
*
other
.
i
+
i
*
other
.
r
};
}
template
<
bool
fwd
,
typename
T2
>
auto
special_mul
(
const
Cmplx
<
T2
>
&
other
)
const
->
Cmplx
<
decltype
(
r
+
other
.
r
)
>
{
using
Tres
=
Cmplx
<
decltype
(
r
+
other
.
r
)
>
;
return
fwd
?
Tres
(
r
*
other
.
r
+
i
*
other
.
i
,
i
*
other
.
r
-
r
*
other
.
i
)
:
Tres
(
r
*
other
.
r
-
i
*
other
.
i
,
r
*
other
.
i
+
i
*
other
.
r
);
}
};
}
#endif
src/mr_util/fft.h
View file @
4af2d1d2
This diff is collapsed.
Click to expand it.
src/mr_util/useful_macros.h
0 → 100644
View file @
4af2d1d2
#ifndef MRUTIL_USEFUL_MACROS_H
#define MRUTIL_USEFUL_MACROS_H
#if defined(__GNUC__)
#define MRUTIL_NOINLINE __attribute__((noinline))
#define MRUTIL_RESTRICT __restrict__
//#define MRUTIL_ALIGNED(align) __attribute__ ((aligned(align)))
#elif defined(_MSC_VER)
#define MRUTIL_NOINLINE __declspec(noinline)
#define MRUTIL_RESTRICT __restrict
#else
#define MRUTIL_NOINLINE
#define MRUTIL_RESTRICT
#endif
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment