Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F4844326
computeDFT.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Subscribers
None
computeDFT.cpp
View Options
//
// File: computeDFT.cpp
//
// MATLAB Coder version : 5.3
// C/C++ source code generated on : 29-Mar-2023 11:20:55
//
// Include Files
#include "computeDFT.h"
#include "FFTImplementationCallback.h"
#include "dereveb_c_rtwutil.h"
#include "rt_nonfinite.h"
#include "coder_array.h"
#include <cmath>
// Function Declarations
static
int
div_s32
(
int
numerator
,
int
denominator
);
// Function Definitions
//
// Arguments : int numerator
// int denominator
// Return Type : int
//
static
int
div_s32
(
int
numerator
,
int
denominator
)
{
int
quotient
;
if
(
denominator
==
0
)
{
if
(
numerator
>=
0
)
{
quotient
=
MAX_int32_T
;
}
else
{
quotient
=
MIN_int32_T
;
}
}
else
{
unsigned
int
b_denominator
;
unsigned
int
b_numerator
;
if
(
numerator
<
0
)
{
b_numerator
=
~
static_cast
<
unsigned
int
>
(
numerator
)
+
1U
;
}
else
{
b_numerator
=
static_cast
<
unsigned
int
>
(
numerator
);
}
if
(
denominator
<
0
)
{
b_denominator
=
~
static_cast
<
unsigned
int
>
(
denominator
)
+
1U
;
}
else
{
b_denominator
=
static_cast
<
unsigned
int
>
(
denominator
);
}
b_numerator
/=
b_denominator
;
if
((
numerator
<
0
)
!=
(
denominator
<
0
))
{
quotient
=
-
static_cast
<
int
>
(
b_numerator
);
}
else
{
quotient
=
static_cast
<
int
>
(
b_numerator
);
}
}
return
quotient
;
}
//
// Arguments : const ::coder::array<double, 2U> &xin
// double nfft
// ::coder::array<creal_T, 2U> &Xx
// ::coder::array<double, 1U> &f
// Return Type : void
//
namespace
coder
{
void
computeDFT
(
const
::
coder
::
array
<
double
,
2U
>
&
xin
,
double
nfft
,
::
coder
::
array
<
creal_T
,
2U
>
&
Xx
,
::
coder
::
array
<
double
,
1U
>
&
f
)
{
array
<
double
,
2U
>
costab
;
array
<
double
,
2U
>
costab1q
;
array
<
double
,
2U
>
sintab
;
array
<
double
,
2U
>
sintabinv
;
array
<
double
,
2U
>
wrappedData
;
array
<
double
,
2U
>
xw
;
double
freq_res
;
double
half_res
;
int
b_remainder
;
int
i
;
int
i1
;
int
k
;
int
loop_ub_tmp
;
int
nFullPasses
;
int
offset
;
loop_ub_tmp
=
static_cast
<
int
>
(
nfft
);
xw
.
set_size
(
loop_ub_tmp
,
xin
.
size
(
1
));
offset
=
static_cast
<
int
>
(
nfft
)
*
xin
.
size
(
1
);
for
(
i
=
0
;
i
<
offset
;
i
++
)
{
xw
[
i
]
=
0.0
;
}
if
(
xin
.
size
(
0
)
>
nfft
)
{
i
=
xin
.
size
(
1
);
for
(
int
j
{
0
};
j
<
i
;
j
++
)
{
if
(
xin
.
size
(
0
)
==
1
)
{
wrappedData
.
set_size
(
1
,
loop_ub_tmp
);
for
(
i1
=
0
;
i1
<
loop_ub_tmp
;
i1
++
)
{
wrappedData
[
i1
]
=
0.0
;
}
}
else
{
wrappedData
.
set_size
(
loop_ub_tmp
,
1
);
for
(
i1
=
0
;
i1
<
loop_ub_tmp
;
i1
++
)
{
wrappedData
[
i1
]
=
0.0
;
}
}
nFullPasses
=
div_s32
(
xin
.
size
(
0
),
static_cast
<
int
>
(
nfft
));
offset
=
nFullPasses
*
static_cast
<
int
>
(
nfft
);
b_remainder
=
(
xin
.
size
(
0
)
-
offset
)
-
1
;
for
(
k
=
0
;
k
<=
b_remainder
;
k
++
)
{
wrappedData
[
k
]
=
xin
[(
offset
+
k
)
+
xin
.
size
(
0
)
*
j
];
}
i1
=
b_remainder
+
2
;
for
(
k
=
i1
;
k
<=
loop_ub_tmp
;
k
++
)
{
wrappedData
[
k
-
1
]
=
0.0
;
}
for
(
b_remainder
=
0
;
b_remainder
<
nFullPasses
;
b_remainder
++
)
{
offset
=
b_remainder
*
static_cast
<
int
>
(
nfft
);
for
(
k
=
0
;
k
<
loop_ub_tmp
;
k
++
)
{
wrappedData
[
k
]
=
wrappedData
[
k
]
+
xin
[(
offset
+
k
)
+
xin
.
size
(
0
)
*
j
];
}
}
offset
=
wrappedData
.
size
(
0
)
*
wrappedData
.
size
(
1
);
for
(
i1
=
0
;
i1
<
offset
;
i1
++
)
{
xw
[
i1
+
xw
.
size
(
0
)
*
j
]
=
wrappedData
[
i1
];
}
}
}
else
{
xw
.
set_size
(
xin
.
size
(
0
),
xin
.
size
(
1
));
offset
=
xin
.
size
(
0
)
*
xin
.
size
(
1
);
for
(
i
=
0
;
i
<
offset
;
i
++
)
{
xw
[
i
]
=
xin
[
i
];
}
}
if
((
xw
.
size
(
0
)
==
0
)
||
(
xw
.
size
(
1
)
==
0
))
{
Xx
.
set_size
(
loop_ub_tmp
,
xw
.
size
(
1
));
offset
=
static_cast
<
int
>
(
nfft
)
*
xw
.
size
(
1
);
for
(
i
=
0
;
i
<
offset
;
i
++
)
{
Xx
[
i
].
re
=
0.0
;
Xx
[
i
].
im
=
0.0
;
}
}
else
{
boolean_T
useRadix2
;
useRadix2
=
((
static_cast
<
int
>
(
nfft
)
>
0
)
&&
((
static_cast
<
int
>
(
nfft
)
&
(
static_cast
<
int
>
(
nfft
)
-
1
))
==
0
));
internal
::
FFTImplementationCallback
::
get_algo_sizes
(
static_cast
<
int
>
(
nfft
),
useRadix2
,
&
nFullPasses
,
&
offset
);
freq_res
=
6.2831853071795862
/
static_cast
<
double
>
(
offset
);
b_remainder
=
offset
/
2
/
2
;
costab1q
.
set_size
(
1
,
b_remainder
+
1
);
costab1q
[
0
]
=
1.0
;
offset
=
b_remainder
/
2
-
1
;
for
(
k
=
0
;
k
<=
offset
;
k
++
)
{
costab1q
[
k
+
1
]
=
std
::
cos
(
freq_res
*
(
static_cast
<
double
>
(
k
)
+
1.0
));
}
i
=
offset
+
2
;
i1
=
b_remainder
-
1
;
for
(
k
=
i
;
k
<=
i1
;
k
++
)
{
costab1q
[
k
]
=
std
::
sin
(
freq_res
*
static_cast
<
double
>
(
b_remainder
-
k
));
}
costab1q
[
b_remainder
]
=
0.0
;
if
(
!
useRadix2
)
{
b_remainder
=
costab1q
.
size
(
1
)
-
1
;
offset
=
(
costab1q
.
size
(
1
)
-
1
)
<<
1
;
costab
.
set_size
(
1
,
offset
+
1
);
sintab
.
set_size
(
1
,
offset
+
1
);
costab
[
0
]
=
1.0
;
sintab
[
0
]
=
0.0
;
sintabinv
.
set_size
(
1
,
offset
+
1
);
for
(
k
=
0
;
k
<
b_remainder
;
k
++
)
{
sintabinv
[
k
+
1
]
=
costab1q
[(
b_remainder
-
k
)
-
1
];
}
i
=
costab1q
.
size
(
1
);
for
(
k
=
i
;
k
<=
offset
;
k
++
)
{
sintabinv
[
k
]
=
costab1q
[
k
-
b_remainder
];
}
for
(
k
=
0
;
k
<
b_remainder
;
k
++
)
{
costab
[
k
+
1
]
=
costab1q
[
k
+
1
];
sintab
[
k
+
1
]
=
-
costab1q
[(
b_remainder
-
k
)
-
1
];
}
i
=
costab1q
.
size
(
1
);
for
(
k
=
i
;
k
<=
offset
;
k
++
)
{
costab
[
k
]
=
-
costab1q
[
offset
-
k
];
sintab
[
k
]
=
-
costab1q
[
k
-
b_remainder
];
}
}
else
{
b_remainder
=
costab1q
.
size
(
1
)
-
1
;
offset
=
(
costab1q
.
size
(
1
)
-
1
)
<<
1
;
costab
.
set_size
(
1
,
offset
+
1
);
sintab
.
set_size
(
1
,
offset
+
1
);
costab
[
0
]
=
1.0
;
sintab
[
0
]
=
0.0
;
for
(
k
=
0
;
k
<
b_remainder
;
k
++
)
{
costab
[
k
+
1
]
=
costab1q
[
k
+
1
];
sintab
[
k
+
1
]
=
-
costab1q
[(
b_remainder
-
k
)
-
1
];
}
i
=
costab1q
.
size
(
1
);
for
(
k
=
i
;
k
<=
offset
;
k
++
)
{
costab
[
k
]
=
-
costab1q
[
offset
-
k
];
sintab
[
k
]
=
-
costab1q
[
k
-
b_remainder
];
}
sintabinv
.
set_size
(
1
,
0
);
}
if
(
useRadix2
)
{
internal
::
FFTImplementationCallback
::
r2br_r2dit_trig
(
xw
,
static_cast
<
int
>
(
nfft
),
costab
,
sintab
,
Xx
);
}
else
{
internal
::
FFTImplementationCallback
::
dobluesteinfft
(
xw
,
nFullPasses
,
static_cast
<
int
>
(
nfft
),
costab
,
sintab
,
sintabinv
,
Xx
);
}
}
freq_res
=
6.2831853071795862
/
nfft
;
if
(
nfft
-
1.0
<
0.0
)
{
costab1q
.
set_size
(
costab1q
.
size
(
0
),
0
);
}
else
if
(
std
::
isinf
(
nfft
-
1.0
)
&&
(
0.0
==
nfft
-
1.0
))
{
costab1q
.
set_size
(
1
,
1
);
costab1q
[
0
]
=
rtNaN
;
}
else
{
offset
=
static_cast
<
int
>
(
std
::
floor
(
nfft
-
1.0
));
costab1q
.
set_size
(
1
,
offset
+
1
);
for
(
i
=
0
;
i
<=
offset
;
i
++
)
{
costab1q
[
i
]
=
i
;
}
}
costab1q
.
set_size
(
1
,
costab1q
.
size
(
1
));
offset
=
costab1q
.
size
(
1
)
-
1
;
for
(
i
=
0
;
i
<=
offset
;
i
++
)
{
costab1q
[
i
]
=
freq_res
*
costab1q
[
i
];
}
half_res
=
freq_res
/
2.0
;
if
(
rt_remd_snf
(
nfft
,
2.0
)
!=
0.0
)
{
double
halfNPTS
;
halfNPTS
=
(
nfft
+
1.0
)
/
2.0
;
costab1q
[
static_cast
<
int
>
(
halfNPTS
)
-
1
]
=
3.1415926535897931
-
half_res
;
costab1q
[
static_cast
<
int
>
(
static_cast
<
unsigned
int
>
(
halfNPTS
))]
=
half_res
+
3.1415926535897931
;
}
else
{
costab1q
[
static_cast
<
int
>
(
nfft
/
2.0
+
1.0
)
-
1
]
=
3.1415926535897931
;
}
costab1q
[
static_cast
<
int
>
(
nfft
)
-
1
]
=
6.2831853071795862
-
freq_res
;
f
.
set_size
(
costab1q
.
size
(
1
));
offset
=
costab1q
.
size
(
1
);
for
(
i
=
0
;
i
<
offset
;
i
++
)
{
f
[
i
]
=
costab1q
[
i
];
}
}
}
// namespace coder
//
// File trailer for computeDFT.cpp
//
// [EOF]
//
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sat, Nov 23, 18:13 (45 s ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1325560
Default Alt Text
computeDFT.cpp (7 KB)
Attached To
R350 av_svc
Event Timeline
Log In to Comment