-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from IntelPython/rambo_dpnp_numpy
Adding implementations of Rambo using numpy-like vector operations
- Loading branch information
Showing
4 changed files
with
63 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import dpnp as np | ||
|
||
|
||
def rambo(nevts, nout, C1, F1, Q1, output): | ||
C = 2.0 * C1 - 1.0 | ||
S = np.sqrt(1 - np.square(C)) | ||
F = 2.0 * np.pi * F1 | ||
Q = -np.log(Q1) | ||
|
||
output[:, :, 0] = Q | ||
output[:, :, 1] = Q * S * np.sin(F) | ||
output[:, :, 2] = Q * S * np.cos(F) | ||
output[:, :, 3] = Q * C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import numba as nb | ||
import numpy as np | ||
|
||
|
||
@nb.njit(parallel=True, fastmath=True) | ||
def rambo(nevts, nout, C1, F1, Q1, output): | ||
C = 2.0 * C1 - 1.0 | ||
S = np.sqrt(1 - np.square(C)) | ||
F = 2.0 * np.pi * F1 | ||
Q = -np.log(Q1) | ||
|
||
output[:, :, 0] = Q | ||
output[:, :, 1] = Q * S * np.sin(F) | ||
output[:, :, 2] = Q * S * np.cos(F) | ||
output[:, :, 3] = Q * C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import numpy as np | ||
|
||
|
||
def rambo(nevts, nout, C1, F1, Q1, output): | ||
for i in range(nevts): | ||
for j in range(nout): | ||
C = 2.0 * C1[i, j] - 1.0 | ||
S = np.sqrt(1 - np.square(C)) | ||
F = 2.0 * np.pi * F1[i, j] | ||
Q = -np.log(Q1[i, j]) | ||
|
||
output[i, j, 0] = Q | ||
output[i, j, 1] = Q * S * np.sin(F) | ||
output[i, j, 2] = Q * S * np.cos(F) | ||
output[i, j, 3] = Q * C |