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
13 changes: 13 additions & 0 deletions rust/docs/matrix/add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの加算を行います。
* サイズが異なる行列同士の加算はエラーを返します。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1.add(&m2).unwrap();
assert_eq!(m1.get(0, 0), Some(&6));
assert_eq!(m1.get(0, 1), Some(&8));
assert_eq!(m1.get(1, 0), Some(&10));
assert_eq!(m1.get(1, 1), Some(&12));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/add_assign.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの加算を行います。
* サイズが異なる行列同士の加算はパニックを引き起こします。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1 += m2;
assert_eq!(m1.get(0, 0), Some(&6));
assert_eq!(m1.get(0, 1), Some(&8));
assert_eq!(m1.get(1, 0), Some(&10));
assert_eq!(m1.get(1, 1), Some(&12));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/add_trait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの加算を行います。
* サイズが異なる行列同士の加算はNoneを返します。
# Examples
```
use matrix::Matrix;
let m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
let m3 = m1 + m2;
assert_eq!(m3.unwrap().get(0, 0), Some(&6));
assert_eq!(m3.unwrap().get(0, 1), Some(&8));
assert_eq!(m3.unwrap().get(1, 0), Some(&10));
assert_eq!(m3.unwrap().get(1, 1), Some(&12));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/add_with.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの加算を行います。
* サイズが異なる行列同士の加算はエラーを返します。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1.add_with::<NaiveAlgorithm, _>(&m2).unwrap();
assert_eq!(m1.get(0, 0), Some(&6));
assert_eq!(m1.get(0, 1), Some(&8));
assert_eq!(m1.get(1, 0), Some(&10));
assert_eq!(m1.get(1, 1), Some(&12));
```
7 changes: 7 additions & 0 deletions rust/docs/matrix/col_iter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
指定した列の要素への参照を返します。
# Examples
```
use matrix::Matrix;
let m: Matrix<i32> = Matrix::with_size(2, 2);
assert_eq!(m.col_iter(0).unwrap().collect::<Vec<&i32>>(), vec![&0, &0]);
```
10 changes: 10 additions & 0 deletions rust/docs/matrix/col_mut_iter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
指定した列の要素への可変参照を返します。
# Examples
```
use matrix::Matrix;
let mut m: Matrix<i32> = Matrix::with_size(2, 2);
if let Some(col_iter) = m.col_mut_iter(0) {
col_iter.for_each(|val| *val = 42);
}
assert_eq!(m.col_iter(0).unwrap().collect::<Vec<&i32>>(), vec![&42, &42]);
```
7 changes: 7 additions & 0 deletions rust/docs/matrix/cols.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
列数を返します。
# Examples
```
use matrix::Matrix;
let m: Matrix<i32> = Matrix::with_size(3, 4); // [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
assert_eq!(m.cols(), 4);
```
14 changes: 14 additions & 0 deletions rust/docs/matrix/div.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
同じサイズの行列同士の要素ごとの除算を行います。
* サイズが異なる行列同士の除算はエラーを返します。
* 0で割る要素がある場合もエラーを返します。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1.div(&m2).unwrap();
assert_eq!(m1.get(0, 0), Some(&0));
assert_eq!(m1.get(0, 1), Some(&0));
assert_eq!(m1.get(1, 0), Some(&0));
assert_eq!(m1.get(1, 1), Some(&0));
```
14 changes: 14 additions & 0 deletions rust/docs/matrix/div_assign.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
同じサイズの行列同士の要素ごとの除算を行います。
* サイズが異なる行列同士の除算はパニックを引き起こします。
* 0で割る要素がある場合もパニックを引き起こします。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[10, 20], [30, 40]]);
let m2: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
m1 /= m2;
assert_eq!(m1.get(0, 0), Some(&10));
assert_eq!(m1.get(0, 1), Some(&10));
assert_eq!(m1.get(1, 0), Some(&10));
assert_eq!(m1.get(1, 1), Some(&10));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/div_trait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの除算を行います。
* サイズが異なる行列同士の除算はNoneを返します。
* 0で割る要素がある場合もNoneを返します。
# Examples
```
use matrix::Matrix;
let m2: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m3 = m1 / m2;
assert_eq!(m3.unwrap().get(0, 0), Some(&10));
assert_eq!(m3.unwrap().get(0, 1), Some(&10));
assert_eq!(m3.unwrap().get(1, 0), Some(&10));
assert_eq!(m3.unwrap().get(1, 1), Some(&10));
```
14 changes: 14 additions & 0 deletions rust/docs/matrix/div_with.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
同じサイズの行列同士の要素ごとの除算を行います。
* サイズが異なる行列同士の除算はエラーを返します。
* 0で割る要素がある場合もエラーを返します。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1.div_with::<NaiveAlgorithm, _>(&m2).unwrap();
assert_eq!(m1.get(0, 0), Some(&0));
assert_eq!(m1.get(0, 1), Some(&0));
assert_eq!(m1.get(1, 0), Some(&0));
assert_eq!(m1.get(1, 1), Some(&0));
```
7 changes: 7 additions & 0 deletions rust/docs/matrix/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
指定した位置の要素への参照を返します。
# Examples
```
use matrix::Matrix;
let m: Matrix<i32> = Matrix::with_size(2, 2);
assert_eq!(m.get(0, 0), Some(&0));
```
10 changes: 10 additions & 0 deletions rust/docs/matrix/get_mut.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
指定した位置の要素への可変参照を返します。
# Examples
```
use matrix::Matrix;
let mut m: Matrix<i32> = Matrix::with_size(2, 2);
if let Some(val) = m.get_mut(0, 0) {
*val = 42;
}
assert_eq!(m.get(0, 0), Some(&42));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/hadamard_mul.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの乗算を行います。
* サイズが異なる行列同士の乗算はエラーを返します。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1.hadamard_mul(&m2).unwrap();
assert_eq!(m1.get(0, 0), Some(&5));
assert_eq!(m1.get(0, 1), Some(&12));
assert_eq!(m1.get(1, 0), Some(&21));
assert_eq!(m1.get(1, 1), Some(&32));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/hadamard_mul_with.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの乗算を行います。
* サイズが異なる行列同士の乗算はエラーを返します。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1.hadamard_mul_with::<NaiveAlgorithm, _>(&m2).unwrap();
assert_eq!(m1.get(0, 0), Some(&5));
assert_eq!(m1.get(0, 1), Some(&12));
assert_eq!(m1.get(1, 0), Some(&21));
assert_eq!(m1.get(1, 1), Some(&32));
```
1 change: 1 addition & 0 deletions rust/docs/matrix/impl_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
タプルインデックスで要素にアクセスできるようにします。
10 changes: 10 additions & 0 deletions rust/docs/matrix/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
タプルインデックスで要素にアクセスします。
# Examples
```
use matrix::Matrix;
let m: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
assert_eq!(m[(0, 0)], 1);
assert_eq!(m[(0, 1)], 2);
assert_eq!(m[(1, 0)], 3);
assert_eq!(m[(1, 1)], 4]);
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/mul.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
行列積を行います。
* 列数と行数が一致しない行列同士の乗算はエラーを返します。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1.mul(&m2).unwrap();
assert_eq!(m1.get(0, 0), Some(&19));
assert_eq!(m1.get(0, 1), Some(&22));
assert_eq!(m1.get(1, 0), Some(&43));
assert_eq!(m1.get(1, 1), Some(&50));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/mul_assign.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
行列積を行います。
* サイズが異なる行列同士の乗算はパニックを引き起こします。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1 *= m2;
assert_eq!(m1.get(0, 0), Some(&19));
assert_eq!(m1.get(0, 1), Some(&22));
assert_eq!(m1.get(1, 0), Some(&43));
assert_eq!(m1.get(1, 1), Some(&50));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/mul_trait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの乗算を行います。
* サイズが異なる行列同士の乗算はNoneを返します。
# Examples
```
use matrix::Matrix;
let m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
let m3 = m1 * m2;
assert_eq!(m3.unwrap().get(0, 0), Some(&19));
assert_eq!(m3.unwrap().get(0, 1), Some(&22));
assert_eq!(m3.unwrap().get(1, 0), Some(&43));
assert_eq!(m3.unwrap().get(1, 1), Some(&50));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/mul_with.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
行列積を行います。
* 列数と行数が一致しない行列同士の乗算はエラーを返します。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1.mul_with::<NaiveAlgorithm, _>(&m2).unwrap();
assert_eq!(m1.get(0, 0), Some(&19));
assert_eq!(m1.get(0, 1), Some(&22));
assert_eq!(m1.get(1, 0), Some(&43));
assert_eq!(m1.get(1, 1), Some(&50));
```
9 changes: 9 additions & 0 deletions rust/docs/matrix/new.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
二次元配列から行列を作成します。
* TはDefaultとCopyトレイトを実装している必要があります。
# Examples
use NeuralNetwork::matrix::Matrix;
assert_eq!(m.get(0, 0), Some(&1));
assert_eq!(m.get(0, 1), Some(&2));
assert_eq!(m.get(1, 0), Some(&3));
assert_eq!(m.get(1, 1), Some(&4));
```
7 changes: 7 additions & 0 deletions rust/docs/matrix/row_iter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
指定した行の要素への参照を返します。
# Examples
```
use matrix::Matrix;
let m: Matrix<i32> = Matrix::with_size(2, 2);
assert_eq!(m.row_iter(0).unwrap().collect::<Vec<&i32>>(), vec![&0, &0]);
```
10 changes: 10 additions & 0 deletions rust/docs/matrix/row_mut_iter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
指定した行の要素への可変参照を返します。
# Examples
```
use matrix::Matrix;
let mut m: Matrix<i32> = Matrix::with_size(2, 2);
if let Some(row_iter) = m.row_mut_iter(0) {
row_iter.for_each(|val| *val = 42);
}
assert_eq!(m.row_mut_iter(0).unwrap().collect::<Vec<&i32>>(), vec![&42, &42]);
```
7 changes: 7 additions & 0 deletions rust/docs/matrix/rows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
行数を返します。
# Examples
```
use matrix::Matrix;
let m: Matrix<i32> = Matrix::with_size(3, 4); // [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
assert_eq!(m.rows(), 3);
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/sub.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの減算を行います。
* サイズが異なる行列同士の減算はエラーを返します。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1.sub(&m2).unwrap();
assert_eq!(m1.get(0, 0), Some(&-4));
assert_eq!(m1.get(0, 1), Some(&-4));
assert_eq!(m1.get(1, 0), Some(&-4));
assert_eq!(m1.get(1, 1), Some(&-4));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/sub_assign.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの減算を行います。
* サイズが異なる行列同士の減算はパニックを引き起こします。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1 -= m2;
assert_eq!(m1.get(0, 0), Some(&-4));
assert_eq!(m1.get(0, 1), Some(&-4));
assert_eq!(m1.get(1, 0), Some(&-4));
assert_eq!(m1.get(1, 1), Some(&-4));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/sub_trait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの減算を行います。
* サイズが異なる行列同士の減算はNoneを返します。
# Examples
```
use matrix::Matrix;
let m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
let m3 = m1 - m2;
assert_eq!(m3.unwrap().get(0, 0), Some(&-4));
assert_eq!(m3.unwrap().get(0, 1), Some(&-4));
assert_eq!(m3.unwrap().get(1, 0), Some(&-4));
assert_eq!(m3.unwrap().get(1, 1), Some(&-4));
```
13 changes: 13 additions & 0 deletions rust/docs/matrix/sub_with.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
同じサイズの行列同士の要素ごとの減算を行います。
* サイズが異なる行列同士の減算はエラーを返します。
# Examples
```
use matrix::Matrix;
let mut m1: Matrix<i32> = Matrix::new([[1, 2], [3, 4]]);
let m2: Matrix<i32> = Matrix::new([[5, 6], [7, 8]]);
m1.sub_with::<NaiveAlgorithm, _>(&m2).unwrap();
assert_eq!(m1.get(0, 0), Some(&-4));
assert_eq!(m1.get(0, 1), Some(&-4));
assert_eq!(m1.get(1, 0), Some(&-4));
assert_eq!(m1.get(1, 1), Some(&-4));
```
12 changes: 12 additions & 0 deletions rust/docs/matrix/with_size.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
サイズを指定して行列を作成します。
* 要素は全てTのデフォルト値で初期化されます。
* TはDefaultとCopyトレイトを実装している必要があります。
# Examples
```
use matrix::Matrix;
let m: Matrix<i32> = Matrix::with_size(2, 2);
assert_eq!(m.get(0, 0), Some(&0));
assert_eq!(m.get(0, 1), Some(&0));
assert_eq!(m.get(1, 0), Some(&0));
assert_eq!(m.get(1, 1), Some(&0));
```
1 change: 1 addition & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod matrix_layout;
pub mod matrix_algorithm;
pub mod matrix;
Loading
Loading