Skip to content

Commit a4afe8b

Browse files
authored
Merge pull request #140 from Jij-Inc/konn/genarray
Array Generation docs
2 parents 4d18503 + 6eacaf7 commit a4afe8b

File tree

4 files changed

+176
-46
lines changed

4 files changed

+176
-46
lines changed

docs/en/releases/unreleased.ipynb

Lines changed: 67 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/ja/releases/unreleased.ipynb

Lines changed: 71 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

markdowns/en/releases/unreleased.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,26 @@ kernelspec:
1919

2020
+++
2121

22-
### Feature 1
22+
### Generating arrays with a shape and generator function
2323

24-
+++
24+
Starting with this version, the {py:func}`~jijmodeling.genarray` function can be used to generate arrays by specifying a shape and a generator function.
25+
This is similar to {py:func}`~numpy.fromfunction` in NumPy.
26+
27+
```{code-cell} ipython3
28+
import jijmodeling as jm
29+
30+
31+
@jm.Problem.define("genarray example")
32+
def problem(problem):
33+
N = problem.Natural()
34+
M = problem.Natural()
35+
a = problem.Float(shape=(N, M))
36+
x = problem.BinaryVar(shape=N)
37+
Sums = problem.NamedExpr(jm.genarray(lambda i, j: a[i, j] * x[i], (N, M)))
38+
39+
40+
problem
41+
```
2542

2643
## Bugfixes
2744

markdowns/ja/releases/unreleased.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,26 @@ kernelspec:
1919

2020
+++
2121

22-
### 機能1
22+
### シェイプと生成関数による配列の生成
2323

24-
+++
24+
本バージョンから、{py:func}`~jijmodeling.genarray` 関数により、シェイプと生成関数を指定して配列を生成できるようになりました。
25+
これは numpy の {py:func}`~numpy.fromfunction` と類似の機能です。
26+
27+
```{code-cell} ipython3
28+
import jijmodeling as jm
29+
30+
31+
@jm.Problem.define("genarray example")
32+
def problem(problem):
33+
N = problem.Natural()
34+
M = problem.Natural()
35+
a = problem.Float(shape=(N, M))
36+
x = problem.BinaryVar(shape=N)
37+
Sums = problem.NamedExpr(jm.genarray(lambda i, j: a[i, j] * x[i], (N, M)))
38+
39+
40+
problem
41+
```
2542

2643
## バグ修正
2744

0 commit comments

Comments
 (0)