Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ jobs:
- name: Install sac2c
run: |
git clone --recursive --single-branch https://gitlab.sac-home.org/sac-group/sac2c.git
cd sac2c && mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=RELEASE ..
make -j2
cp sac2c_p /usr/local/bin/sac2c
cd sac2c
make release -j2
cp build_p/sac2c_p /usr/local/bin/sac2c
sac2c -V
- name: Create build dir
run: |
Expand Down Expand Up @@ -64,10 +63,9 @@ jobs:
- name: Install sac2c
run: |
git clone --recursive --single-branch https://gitlab.sac-home.org/sac-group/sac2c.git
cd sac2c && mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=RELEASE ..
make -j2
cp sac2c_p /usr/local/bin/sac2c
cd sac2c
make release -j2
cp build_p/sac2c_p /usr/local/bin/sac2c
sac2c -V
- name: Create build dir
run: |
Expand Down Expand Up @@ -106,10 +104,9 @@ jobs:
- name: Install sac2c
run: |
git clone --recursive --single-branch https://gitlab.sac-home.org/sac-group/sac2c.git
cd sac2c && mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=RELEASE ..
make -j2
cp sac2c_p /usr/local/bin/sac2c
cd sac2c
make release -j2
cp build_p/sac2c_p /usr/local/bin/sac2c
sac2c -V
- name: Create build dir
run: |
Expand Down
1 change: 1 addition & 0 deletions src/numerical/ComplexMath.sac
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma safe
module ComplexMath;

export all;
Expand Down
4 changes: 3 additions & 1 deletion src/numerical/Math.sac
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma safe
module Math;

use ScalarArith: all;
Expand Down Expand Up @@ -245,7 +246,8 @@ external float, float modf(float X);
*
******************************************************************************/

inline int pow2(int a) {
inline int pow2(int a)
{
return _shl_SxS_(1, a);
}

Expand Down
1 change: 1 addition & 0 deletions src/numerical/MathArray.sac
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma safe
module MathArray;

export all;
Expand Down
1 change: 1 addition & 0 deletions src/numerical/Numerical.sac
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma safe
module Numerical;

import Math: all;
Expand Down
45 changes: 24 additions & 21 deletions src/random/Xoshiro.sac
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
/**
/******************************************************************************
*
* # Introduction
*
* This module implements pseudo-random number generators (PRNGs) for
* Monte-Carlo simulations and related algorithms. As of April 2025,
* the Xoshiro family is state of the art. We currently do not offer
* This module implements pseudo-random number generators (PRNGs) for
* Monte-Carlo simulations and related algorithms. As of April 2025,
* the Xoshiro family is state of the art. We currently do not offer
* cryptographically-secure PRNGS.
*
*
* A PRNG is a function [state space] -> [unsigned int type] x [state space]
* The unsigned integer can be converted to a real (float or double) of
* various distributions.
* The unsigned integer can be converted to a real (float or double) of
* various distributions.
*
* # API
*
* The 64-bit version has an l-suffix to avoid name conflicts.
*
*
* ## Basic
*
* For generating double
* ulong, struct State256 xoshiro256p(struct State256 state)
*
*
* For generating float
* uint, struct State128 xoshiro128p(struct State128 state)
*
Expand All @@ -39,7 +40,7 @@
* float , float to_normal(uint u1, uint u2, float mean, float stddev)
*
* ## Multithreading
*
*
* For parallel exeuction, we can generate an array of
* states that are 2^192, 2^96 apart
* This can be created with
Expand Down Expand Up @@ -79,13 +80,15 @@
* of SIMD-lanes, but struct is not yet mature enough to compile this
* efficiently.
* TODO: The parallel method allocates and copies the rows.
**/

*
******************************************************************************/
#pragma safe
module Xoshiro;

use Array: all;
use ScalarArith: all;
use Math: all;
export all except {rotl, splitmix64, srand_time};

export all except { rotl, splitmix64, srand_time };

struct State256 {
ulong s0l;
Expand Down Expand Up @@ -180,7 +183,7 @@ struct State256 jumpl(struct State256 state)
LOOP_BODY_ULONG(1)
LOOP_BODY_ULONG(2)
LOOP_BODY_ULONG(3)

return State256 {.s0l = s0, .s1l = s1, .s2l = s2, .s3l = s3};
}

Expand Down Expand Up @@ -213,7 +216,7 @@ struct State128 jump(struct State128 state)
LOOP_BODY_UINT(1)
LOOP_BODY_UINT(2)
LOOP_BODY_UINT(3)

return State128 {.s0 = s0, .s1 = s1, .s2 = s2, .s3 = s3};
}

Expand Down Expand Up @@ -267,7 +270,7 @@ double, double to_normal(ulong u1, ulong u2, double mean, double stddev)
{
U1 = to_uniform(u1, 0d, 1d);
U2 = to_uniform(u2, 0d, 1d);

Z1 = sqrt(-2d * log(U1)) * cos(2d * pi() * U2);
Z2 = sqrt(-2d * log(U1)) * sin(2d * pi() * U2);

Expand All @@ -279,7 +282,7 @@ float, float to_normal(uint u1, uint u2, float mean, float stddev)
{
U1 = to_uniform(u1, 0f, 1f);
U2 = to_uniform(u2, 0f, 1f);

Z1 = sqrt(-2f * log(U1)) * cos(2f * tof(pi()) * U2);
Z2 = sqrt(-2f * log(U1)) * sin(2f * tof(pi()) * U2);

Expand All @@ -300,7 +303,7 @@ external ulong srand_time();

struct State256 srand256()
{
s0 = srand_time();
s0 = srand_time();
s1 = splitmix64(s0);
s2 = splitmix64(s1);
s3 = splitmix64(s2);
Expand All @@ -310,11 +313,11 @@ struct State256 srand256()

struct State128 srand128()
{
s0 = srand_time();
s0 = srand_time();
s1 = splitmix64(s0);
s2 = splitmix64(s1);
s3 = splitmix64(s2);

return State128 {.s0 = _toui_S_(s0), .s1 = _toui_S_(s1),
return State128 {.s0 = _toui_S_(s0), .s1 = _toui_S_(s1),
.s2 = _toui_S_(s2), .s3 = _toui_S_(s3)};
}
4 changes: 1 addition & 3 deletions src/structures/Array.sac
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module Array;

import ScalarArith: all;
import ArrayArith: all;
import ArrayBasics: all;
import ArrayReduce: all;
Expand All @@ -11,7 +12,4 @@ import ArrayTransform: all;
import ArrayTransformApl: all;
#endif /* EXT_STDLIB */

// Do not import ScalarArith again; it is already imported through ArrayArith
// import ScalarArith: all;

export all;
8 changes: 3 additions & 5 deletions src/structures/ArrayArith.xsac
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module ArrayArith;

import ScalarArith: all;

export all;

#include "builtin.mac"
Expand Down Expand Up @@ -64,21 +62,21 @@ b[d>0:shp] name(a A, a[d>0:shp] B) \

#define MAP_BIN_INT_VxV(name, op) \
inline \
int[n] (name)(int[n] A, int[n] B) \
int[n] name(int[n] A, int[n] B) \
{ \
return _##op##_VxV_(A, B); \
}

#define MAP_BIN_INT_VxS(name, op) \
inline \
int[n] (name)(int[n] A, int B) \
int[n] name(int[n] A, int B) \
{ \
return _##op##_VxS_(A, B); \
}

#define MAP_BIN_INT_SxV(name, op) \
inline \
int[n] (name)(int A, int[n] B) \
int[n] name(int A, int[n] B) \
{ \
return _##op##_SxV_(A, B); \
}
Expand Down
1 change: 1 addition & 0 deletions src/structures/Quaternion.xsac
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma safe
module Quaternion;

export all;
Expand Down