Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TRACY3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
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
PA
Optics
TRACY3
Commits
41173248
Commit
41173248
authored
14 years ago
by
zhang
Browse files
Options
Downloads
Patches
Plain Diff
15/03/2011
1) Add comments
parent
2f2c5497
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tracy/tracy/src/mathlib.cc
+103
-0
103 additions, 0 deletions
tracy/tracy/src/mathlib.cc
with
103 additions
and
0 deletions
tracy/tracy/src/mathlib.cc
+
103
−
0
View file @
41173248
...
...
@@ -39,15 +39,68 @@ void iniranf(const long i)
rseed0
=
i
;
rseed
=
i
;
}
#define k 19
#define c 656329L
#define m 100000001
/****************************************************************************/
/* void newseed(void)
Purpose: define a new seed
input:
none
output:
none
return:
none
global variables:
rseed0
rseed
k, c, m
specific functions:
none
comments
none
****************************************************************************/
void
newseed
(
void
)
{
rseed0
=
(
k
*
rseed0
+
c
)
%
m
;
rseed
=
(
rseed0
+
54321
)
%
m
;
}
/****************************************************************************/
/* double ranf(void)
Purpose: Generate a random number with rectangular distribution/uniform
distribution between the value [0, m]
input:
none
output:
none
return:
random number of type double
global variables:
rseed0
rseed
k, c, m
specific functions:
none
comments
none
****************************************************************************/
double
ranf
(
void
)
{
/* Generate random number with rectangular distribution */
...
...
@@ -58,7 +111,30 @@ double ranf(void)
#undef c
#undef m
/****************************************************************************/
/* void setrancut(double cut)
Purpose: Set a cut for normal distribution
input:
cut : number of sigma for cutting the distribution
output:
none
return:
none
global variables:
normcut_
specific functions:
none
comments
none
****************************************************************************/
void
setrancut
(
const
double
cut
)
{
...
...
@@ -68,7 +144,34 @@ void setrancut(const double cut)
normcut_
=
cut
;
}
/****************************************************************************/
/* double normranf(void)
Purpose:
Generate random numbers with Gaussian/normal distribution (m=0, sigma=1)
and cut normcut_
input:
none
output:
none
return:
random number
global variables:
normcut_
maxiter
specific functions:
ranf
comments
none
****************************************************************************/
/* maximum number of iteration to generate the random number */
#define maxiter 100
double
normranf
(
void
)
{
...
...
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