Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
miscmaths
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
miscmaths
Commits
5ee22883
Commit
5ee22883
authored
21 years ago
by
Mark Jenkinson
Browse files
Options
Downloads
Patches
Plain Diff
Added sinc
parent
3ef18f1f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
miscmaths.cc
+18
-0
18 additions, 0 deletions
miscmaths.cc
miscmaths.h
+3
-0
3 additions, 0 deletions
miscmaths.h
with
21 additions
and
0 deletions
miscmaths.cc
+
18
−
0
View file @
5ee22883
...
...
@@ -26,6 +26,24 @@ namespace MISCMATHS {
// using std::pow;
using
std
::
atan2
;
float
Sinc
(
const
float
x
)
{
if
(
fabs
(
x
)
<
1e-9
)
{
return
1
-
x
*
x
*
M_PI
*
M_PI
/
6.0
;
}
else
{
return
sin
(
M_PI
*
x
)
/
(
M_PI
*
x
);
}
}
double
Sinc
(
const
double
x
)
{
if
(
fabs
(
x
)
<
1e-9
)
{
return
1
-
x
*
x
*
M_PI
*
M_PI
/
6.0
;
}
else
{
return
sin
(
M_PI
*
x
)
/
(
M_PI
*
x
);
}
}
// General string/IO functions
bool
isnum
(
const
string
&
str
)
...
...
This diff is collapsed.
Click to expand it.
miscmaths.h
+
3
−
0
View file @
5ee22883
...
...
@@ -85,6 +85,9 @@ namespace MISCMATHS {
inline
double
sqrt
(
int
x
)
{
return
std
::
sqrt
((
double
)
x
);
}
inline
double
log
(
int
x
)
{
return
std
::
log
((
double
)
x
);
}
float
Sinc
(
const
float
x
);
double
Sinc
(
const
double
x
);
int
periodicclamp
(
int
x
,
int
x1
,
int
x2
);
template
<
class
S
,
class
T
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment