From 9c243d76a87bce38f3da0a0374ed68af396a6931 Mon Sep 17 00:00:00 2001 From: OtonariS Date: Sun, 31 May 2026 00:20:21 +0900 Subject: [PATCH 1/9] =?UTF-8?q?MatrixArray=E6=A7=8B=E9=80=A0=E4=BD=93?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85=E3=81=97=E3=80=81=E8=A1=8C=E5=88=97?= =?UTF-8?q?=E3=81=AE=E7=94=9F=E6=88=90=E3=81=A8=E8=A6=81=E7=B4=A0=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/Cargo.lock | 7 +++++ rust/src/lib.rs | 1 + rust/src/matrix_array.rs | 55 ++++++++++++++++++++++++++++++++++++ rust/target/.rustc_info.json | 1 + rust/target/CACHEDIR.TAG | 3 ++ rust/target/flycheck0/stderr | 1 + rust/target/flycheck0/stdout | 6 ++++ 7 files changed, 74 insertions(+) create mode 100644 rust/Cargo.lock create mode 100644 rust/src/lib.rs create mode 100644 rust/src/matrix_array.rs create mode 100644 rust/target/.rustc_info.json create mode 100644 rust/target/CACHEDIR.TAG create mode 100644 rust/target/flycheck0/stderr create mode 100644 rust/target/flycheck0/stdout diff --git a/rust/Cargo.lock b/rust/Cargo.lock new file mode 100644 index 0000000..20af5cf --- /dev/null +++ b/rust/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "NeuralNetwork" +version = "0.1.0" diff --git a/rust/src/lib.rs b/rust/src/lib.rs new file mode 100644 index 0000000..001222a --- /dev/null +++ b/rust/src/lib.rs @@ -0,0 +1 @@ +pub mod matrix_array; \ No newline at end of file diff --git a/rust/src/matrix_array.rs b/rust/src/matrix_array.rs new file mode 100644 index 0000000..813460b --- /dev/null +++ b/rust/src/matrix_array.rs @@ -0,0 +1,55 @@ +pub struct MatrixArray{ + data: Vec, + row: usize, + col: usize +} +impl MatrixArray +where T: Default, T: Clone +{ + pub fn with_size(row: usize, col: usize) -> Self{ + Self { + data: vec![T::default(); row*col], + row: row, + col: col + } + } +} +impl MatrixArray +{ + pub fn with_data(array_2d: [[T; COL];ROW]) -> Self + where T: ToOwned + { + Self { + data: array_2d.into_iter().flatten().collect::>(), + row: ROW, + col: COL + } + } + pub fn get(&self, row: usize, col: usize)->Option<&T>{ + let idx = row*self.col + col; + self.data.get(idx) + } +} +impl MatrixArray +{ + pub fn with_data(array_2d: [[T; COL];ROW]) -> Self + where T: ToOwned, T: Clone + { + let array_2d_ref = &array_2d; + let data: Vec = (0..COL) + .flat_map(move |c| { + (0..ROW).map(move |r| array_2d_ref[r][c].clone()) + }) + .collect(); + + Self { + data, + row: ROW, + col: COL + } + } + pub fn get(&self, row: usize, col: usize)->Option<&T>{ + let idx = col * self.row + row; + self.data.get(idx) + } +} \ No newline at end of file diff --git a/rust/target/.rustc_info.json b/rust/target/.rustc_info.json new file mode 100644 index 0000000..96e3b1f --- /dev/null +++ b/rust/target/.rustc_info.json @@ -0,0 +1 @@ +{"rustc_fingerprint":6916924876317518318,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\sanae\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.95.0 (59807616e 2026-04-14)\nbinary: rustc\ncommit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860\ncommit-date: 2026-04-14\nhost: x86_64-pc-windows-msvc\nrelease: 1.95.0\nLLVM version: 22.1.2\n","stderr":""},"12004014463585500860":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\sanae\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\nemscripten_wasm_eh\nfmt_debug=\"full\"\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"lahfsahf\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_feature=\"x87\"\ntarget_has_atomic\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"128\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_has_reliable_f128\ntarget_has_reliable_f16\ntarget_has_reliable_f16_math\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"pc\"\nub_checks\nwindows\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/rust/target/CACHEDIR.TAG b/rust/target/CACHEDIR.TAG new file mode 100644 index 0000000..20d7c31 --- /dev/null +++ b/rust/target/CACHEDIR.TAG @@ -0,0 +1,3 @@ +Signature: 8a477f597d28d172789f06886806bc55 +# This file is a cache directory tag created by cargo. +# For information about cache directory tags see https://bford.info/cachedir/ diff --git a/rust/target/flycheck0/stderr b/rust/target/flycheck0/stderr new file mode 100644 index 0000000..f244f75 --- /dev/null +++ b/rust/target/flycheck0/stderr @@ -0,0 +1 @@ + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s diff --git a/rust/target/flycheck0/stdout b/rust/target/flycheck0/stdout new file mode 100644 index 0000000..3f695b3 --- /dev/null +++ b/rust/target/flycheck0/stdout @@ -0,0 +1,6 @@ +{"reason":"compiler-message","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"message":{"$message_type":"diagnostic","message":"crate `NeuralNetwork` should have a snake case name","code":{"code":"non_snake_case","explanation":null},"level":"warning","spans":[{"file_name":"src\\lib.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":true,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"convert the identifier to snake case: `neural_network`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"`#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[93mwarning\u001b[0m\u001b[1m\u001b[97m: crate `NeuralNetwork` should have a snake case name\u001b[0m\n \u001b[1m\u001b[96m|\u001b[0m\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mhelp\u001b[0m: convert the identifier to snake case: `neural_network`\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mnote\u001b[0m: `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default\n\n"}} +{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-b49945cb8e1a061f.rmeta"],"executable":null,"fresh":true} +{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-9b9040de17136bb0.rmeta"],"executable":null,"fresh":true} +{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-a18b77050cc20fad.rmeta"],"executable":null,"fresh":true} +{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-23b176100197719a.rmeta"],"executable":null,"fresh":true} +{"reason":"build-finished","success":true} From 84dcd4a22fa67b9332d7a0e7ba69e7120c2af292 Mon Sep 17 00:00:00 2001 From: OtonariS Date: Sun, 31 May 2026 13:34:40 +0900 Subject: [PATCH 2/9] =?UTF-8?q?MatrixArray=E6=A7=8B=E9=80=A0=E4=BD=93?= =?UTF-8?q?=E3=81=AE=E3=83=A1=E3=82=A4=E3=83=B3=E9=96=A2=E6=95=B0=E3=82=92?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E3=81=97=E3=80=81=E8=A1=8C=E5=88=97=E3=81=AE?= =?UTF-8?q?=E7=94=9F=E6=88=90=E3=81=A8=E8=A1=A8=E7=A4=BA=E6=A9=9F=E8=83=BD?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/src/main.rs | 7 +- rust/src/matrix_array.rs | 136 ++++++++++++++++++++++++++--------- rust/target/.rustc_info.json | 2 +- rust/target/flycheck0/stderr | 13 +++- rust/target/flycheck0/stdout | 4 +- 5 files changed, 123 insertions(+), 39 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index e7a11a9..f56d4f7 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -1,3 +1,6 @@ +use NeuralNetwork::matrix_array; + fn main() { - println!("Hello, world!"); -} + let mtx = matrix_array::MatrixArray::::with_size(3, 4); + println!("{}", mtx); +} \ No newline at end of file diff --git a/rust/src/matrix_array.rs b/rust/src/matrix_array.rs index 813460b..a59f0b2 100644 --- a/rust/src/matrix_array.rs +++ b/rust/src/matrix_array.rs @@ -1,55 +1,125 @@ -pub struct MatrixArray{ +use core::fmt; + +pub struct MatrixArray { data: Vec, row: usize, - col: usize + col: usize, } -impl MatrixArray -where T: Default, T: Clone -{ - pub fn with_size(row: usize, col: usize) -> Self{ - Self { - data: vec![T::default(); row*col], - row: row, - col: col + +impl MatrixArray { + pub fn with_size(row: usize, col: usize) -> Self + where + T: Default + Clone, + { + Self { + data: vec![T::default(); row * col], + row, + col, } } } -impl MatrixArray -{ - pub fn with_data(array_2d: [[T; COL];ROW]) -> Self - where T: ToOwned - { - Self { - data: array_2d.into_iter().flatten().collect::>(), - row: ROW, - col: COL + +// ========================================== +// 行優先 (Row-Major) の実装 +// ========================================== +impl MatrixArray { + pub fn with_data(array_2d: [[T; COL]; ROW]) -> Self { + Self { + // 💡 into_iter() を使っているので ToOwned の制約自体を削除できます! + data: array_2d.into_iter().flatten().collect::>(), + row: ROW, + col: COL, } } - pub fn get(&self, row: usize, col: usize)->Option<&T>{ - let idx = row*self.col + col; + + pub fn get(&self, row: usize, col: usize) -> Option<&T> { + let idx = row * self.col + col; self.data.get(idx) } + + pub fn get_mut_row(&mut self, row: usize) -> impl Iterator { + self.data.iter_mut().skip(self.col * row).take(self.col) + } + pub fn get_mut_column(&mut self, col: usize) -> impl Iterator { + self.data.iter_mut().skip(col).step_by(self.col).take(self.row) + } + + pub fn get_row(&self, row: usize) -> impl Iterator { + self.data.iter().skip(self.col * row).take(self.col) + } + pub fn get_column(&self, col: usize) -> impl Iterator { + self.data.iter().skip(col).step_by(self.col).take(self.row) + } } -impl MatrixArray -{ - pub fn with_data(array_2d: [[T; COL];ROW]) -> Self - where T: ToOwned, T: Clone + +// ========================================== +// 列優先 (Column-Major) の実装 +// ========================================== +impl MatrixArray { + pub fn with_data(array_2d: [[T; COL]; ROW]) -> Self + where + T: Clone, { let array_2d_ref = &array_2d; let data: Vec = (0..COL) - .flat_map(move |c| { - (0..ROW).map(move |r| array_2d_ref[r][c].clone()) - }) + .flat_map(move |c| (0..ROW).map(move |r| array_2d_ref[r][c].clone())) .collect(); - Self { - data, - row: ROW, - col: COL + Self { + data, + row: ROW, + col: COL, } } - pub fn get(&self, row: usize, col: usize)->Option<&T>{ + + pub fn get(&self, row: usize, col: usize) -> Option<&T> { let idx = col * self.row + row; self.data.get(idx) } + + pub fn get_mut_row(&mut self, row: usize) -> impl Iterator { + self.data.iter_mut().skip(row).step_by(self.row).take(self.col) + } + pub fn get_mut_column(&mut self, col: usize) -> impl Iterator { + self.data.iter_mut().skip(col * self.row).take(self.row) + } + + pub fn get_row(&self, row: usize) -> impl Iterator { + self.data.iter().skip(row).step_by(self.row).take(self.col) + } + pub fn get_column(&self, col: usize) -> impl Iterator { + self.data.iter().skip(col * self.row).take(self.row) + } +} + +// ========================================== +// トレイト実装 +// ========================================== +impl fmt::Display for MatrixArray { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut result = String::new(); + + for r in 0..self.row { + for c in self.get_row(r) { + result.push_str(&format!("{}\t", c)); + } + result.push('\n'); + } + + write!(f, "{}", result) + } +} +impl fmt::Display for MatrixArray { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut result = String::new(); + + for r in 0..self.row { + for c in self.get_row(r) { + result.push_str(&format!("{}\t", c)); + } + result.push('\n'); + } + + write!(f, "{}", result) + } } \ No newline at end of file diff --git a/rust/target/.rustc_info.json b/rust/target/.rustc_info.json index 96e3b1f..992b458 100644 --- a/rust/target/.rustc_info.json +++ b/rust/target/.rustc_info.json @@ -1 +1 @@ -{"rustc_fingerprint":6916924876317518318,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\sanae\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.95.0 (59807616e 2026-04-14)\nbinary: rustc\ncommit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860\ncommit-date: 2026-04-14\nhost: x86_64-pc-windows-msvc\nrelease: 1.95.0\nLLVM version: 22.1.2\n","stderr":""},"12004014463585500860":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\sanae\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\nemscripten_wasm_eh\nfmt_debug=\"full\"\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"lahfsahf\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_feature=\"x87\"\ntarget_has_atomic\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"128\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_has_reliable_f128\ntarget_has_reliable_f16\ntarget_has_reliable_f16_math\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"pc\"\nub_checks\nwindows\n","stderr":""}},"successes":{}} \ No newline at end of file +{"rustc_fingerprint":15185187270388882405,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\sanae\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.95.0 (59807616e 2026-04-14)\nbinary: rustc\ncommit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860\ncommit-date: 2026-04-14\nhost: x86_64-pc-windows-msvc\nrelease: 1.95.0\nLLVM version: 22.1.2\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/rust/target/flycheck0/stderr b/rust/target/flycheck0/stderr index f244f75..1425724 100644 --- a/rust/target/flycheck0/stderr +++ b/rust/target/flycheck0/stderr @@ -1 +1,12 @@ - Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s + 0.029064000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: stale: changed "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs" + 0.029122900s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: (vs) "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-9b9040de17136bb0\\dep-bin-NeuralNetwork" + 0.029135200s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: FileTime { seconds: 13424675637, nanos: 17807500 } < FileTime { seconds: 13424675640, nanos: 581835600 } + 0.029424900s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: false }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } + 0.029465500s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleItem(ChangedFile { reference: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-9b9040de17136bb0\\dep-bin-NeuralNetwork", reference_mtime: FileTime { seconds: 13424675637, nanos: 17807500 }, stale: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", stale_mtime: FileTime { seconds: 13424675640, nanos: 581835600 } })) + 0.030546400s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: stale: changed "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs" + 0.030564000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: (vs) "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-a18b77050cc20fad\\dep-test-bin-NeuralNetwork" + 0.030572800s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: FileTime { seconds: 13424675637, nanos: 17807500 } < FileTime { seconds: 13424675640, nanos: 581835600 } + 0.030859400s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: true }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } + 0.030884100s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleItem(ChangedFile { reference: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-a18b77050cc20fad\\dep-test-bin-NeuralNetwork", reference_mtime: FileTime { seconds: 13424675637, nanos: 17807500 }, stale: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", stale_mtime: FileTime { seconds: 13424675640, nanos: 581835600 } })) + Checking NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.23s diff --git a/rust/target/flycheck0/stdout b/rust/target/flycheck0/stdout index 3f695b3..e71d0a3 100644 --- a/rust/target/flycheck0/stdout +++ b/rust/target/flycheck0/stdout @@ -1,6 +1,6 @@ {"reason":"compiler-message","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"message":{"$message_type":"diagnostic","message":"crate `NeuralNetwork` should have a snake case name","code":{"code":"non_snake_case","explanation":null},"level":"warning","spans":[{"file_name":"src\\lib.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":true,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"convert the identifier to snake case: `neural_network`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"`#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[93mwarning\u001b[0m\u001b[1m\u001b[97m: crate `NeuralNetwork` should have a snake case name\u001b[0m\n \u001b[1m\u001b[96m|\u001b[0m\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mhelp\u001b[0m: convert the identifier to snake case: `neural_network`\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mnote\u001b[0m: `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default\n\n"}} {"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-b49945cb8e1a061f.rmeta"],"executable":null,"fresh":true} -{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-9b9040de17136bb0.rmeta"],"executable":null,"fresh":true} -{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-a18b77050cc20fad.rmeta"],"executable":null,"fresh":true} {"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-23b176100197719a.rmeta"],"executable":null,"fresh":true} +{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-a18b77050cc20fad.rmeta"],"executable":null,"fresh":false} +{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-9b9040de17136bb0.rmeta"],"executable":null,"fresh":false} {"reason":"build-finished","success":true} From f3cafdac38a3220cb3ade0b36acbf209d857c7ad Mon Sep 17 00:00:00 2001 From: OtonariS Date: Sun, 31 May 2026 13:48:45 +0900 Subject: [PATCH 3/9] =?UTF-8?q?MatrixArray=E6=A7=8B=E9=80=A0=E4=BD=93?= =?UTF-8?q?=E3=81=AE=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=AB=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=83=8F=E3=83=B3=E3=83=89=E3=83=AA=E3=83=B3?= =?UTF-8?q?=E3=82=B0=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=80=81=E8=A1=8C?= =?UTF-8?q?=E5=88=97=E3=81=AE=E8=A6=81=E7=B4=A0=E5=8F=96=E5=BE=97=E6=99=82?= =?UTF-8?q?=E3=81=AB=E7=AF=84=E5=9B=B2=E5=A4=96=E3=82=A2=E3=82=AF=E3=82=BB?= =?UTF-8?q?=E3=82=B9=E3=82=92=E9=98=B2=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/src/matrix_array.rs | 57 +++++++++++++++++++++++------------- rust/target/.rustc_info.json | 2 +- rust/target/flycheck0/stderr | 22 +++++++------- rust/target/flycheck0/stdout | 2 +- 4 files changed, 49 insertions(+), 34 deletions(-) diff --git a/rust/src/matrix_array.rs b/rust/src/matrix_array.rs index a59f0b2..6935768 100644 --- a/rust/src/matrix_array.rs +++ b/rust/src/matrix_array.rs @@ -25,7 +25,6 @@ impl MatrixArray { impl MatrixArray { pub fn with_data(array_2d: [[T; COL]; ROW]) -> Self { Self { - // 💡 into_iter() を使っているので ToOwned の制約自体を削除できます! data: array_2d.into_iter().flatten().collect::>(), row: ROW, col: COL, @@ -33,22 +32,28 @@ impl MatrixArray { } pub fn get(&self, row: usize, col: usize) -> Option<&T> { + if row >= self.row || col >= self.col { return None; } + let idx = row * self.col + col; self.data.get(idx) } - pub fn get_mut_row(&mut self, row: usize) -> impl Iterator { - self.data.iter_mut().skip(self.col * row).take(self.col) + pub fn get_mut_row(&mut self, row: usize) -> Option> { + if self.row <= row { return None; } + Some(self.data.iter_mut().skip(self.col * row).take(self.col)) } - pub fn get_mut_column(&mut self, col: usize) -> impl Iterator { - self.data.iter_mut().skip(col).step_by(self.col).take(self.row) + pub fn get_mut_column(&mut self, col: usize) -> Option> { + if self.col <= col { return None; } + Some(self.data.iter_mut().skip(col).step_by(self.col).take(self.row)) } - pub fn get_row(&self, row: usize) -> impl Iterator { - self.data.iter().skip(self.col * row).take(self.col) + pub fn get_row(&self, row: usize) -> Option> { + if self.row <= row { return None; } + Some(self.data.iter().skip(self.col * row).take(self.col)) } - pub fn get_column(&self, col: usize) -> impl Iterator { - self.data.iter().skip(col).step_by(self.col).take(self.row) + pub fn get_column(&self, col: usize) -> Option> { + if self.col <= col { return None; } + Some(self.data.iter().skip(col).step_by(self.col).take(self.row)) } } @@ -73,22 +78,28 @@ impl MatrixArray { } pub fn get(&self, row: usize, col: usize) -> Option<&T> { + if row >= self.row || col >= self.col { return None; } + let idx = col * self.row + row; self.data.get(idx) } - pub fn get_mut_row(&mut self, row: usize) -> impl Iterator { - self.data.iter_mut().skip(row).step_by(self.row).take(self.col) + pub fn get_mut_row(&mut self, row: usize) -> Option> { + if self.row <= row { return None; } + Some(self.data.iter_mut().skip(row).step_by(self.row).take(self.col)) } - pub fn get_mut_column(&mut self, col: usize) -> impl Iterator { - self.data.iter_mut().skip(col * self.row).take(self.row) + pub fn get_mut_column(&mut self, col: usize) -> Option> { + if self.col <= col { return None; } + Some(self.data.iter_mut().skip(col * self.row).take(self.row)) } - pub fn get_row(&self, row: usize) -> impl Iterator { - self.data.iter().skip(row).step_by(self.row).take(self.col) + pub fn get_row(&self, row: usize) -> Option> { + if self.row <= row { return None; } + Some(self.data.iter().skip(row).step_by(self.row).take(self.col)) } - pub fn get_column(&self, col: usize) -> impl Iterator { - self.data.iter().skip(col * self.row).take(self.row) + pub fn get_column(&self, col: usize) -> Option> { + if self.col <= col { return None; } + Some(self.data.iter().skip(col * self.row).take(self.row)) } } @@ -100,8 +111,10 @@ impl fmt::Display for MatrixArray { let mut result = String::new(); for r in 0..self.row { - for c in self.get_row(r) { - result.push_str(&format!("{}\t", c)); + if let Some(row_iter) = self.get_row(r) { + for c in row_iter { + result.push_str(&format!("{}\t", c)); + } } result.push('\n'); } @@ -114,8 +127,10 @@ impl fmt::Display for MatrixArray { let mut result = String::new(); for r in 0..self.row { - for c in self.get_row(r) { - result.push_str(&format!("{}\t", c)); + if let Some(row_iter) = self.get_row(r) { + for c in row_iter { + result.push_str(&format!("{}\t", c)); + } } result.push('\n'); } diff --git a/rust/target/.rustc_info.json b/rust/target/.rustc_info.json index 992b458..e7ae7f6 100644 --- a/rust/target/.rustc_info.json +++ b/rust/target/.rustc_info.json @@ -1 +1 @@ -{"rustc_fingerprint":15185187270388882405,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\sanae\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.95.0 (59807616e 2026-04-14)\nbinary: rustc\ncommit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860\ncommit-date: 2026-04-14\nhost: x86_64-pc-windows-msvc\nrelease: 1.95.0\nLLVM version: 22.1.2\n","stderr":""}},"successes":{}} \ No newline at end of file +{"rustc_fingerprint":6916924876317518318,"outputs":{"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.95.0 (59807616e 2026-04-14)\nbinary: rustc\ncommit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860\ncommit-date: 2026-04-14\nhost: x86_64-pc-windows-msvc\nrelease: 1.95.0\nLLVM version: 22.1.2\n","stderr":""},"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\sanae\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/rust/target/flycheck0/stderr b/rust/target/flycheck0/stderr index 1425724..25a7cbe 100644 --- a/rust/target/flycheck0/stderr +++ b/rust/target/flycheck0/stderr @@ -1,12 +1,12 @@ - 0.029064000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: stale: changed "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs" - 0.029122900s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: (vs) "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-9b9040de17136bb0\\dep-bin-NeuralNetwork" - 0.029135200s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: FileTime { seconds: 13424675637, nanos: 17807500 } < FileTime { seconds: 13424675640, nanos: 581835600 } - 0.029424900s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: false }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } - 0.029465500s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleItem(ChangedFile { reference: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-9b9040de17136bb0\\dep-bin-NeuralNetwork", reference_mtime: FileTime { seconds: 13424675637, nanos: 17807500 }, stale: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", stale_mtime: FileTime { seconds: 13424675640, nanos: 581835600 } })) - 0.030546400s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: stale: changed "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs" - 0.030564000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: (vs) "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-a18b77050cc20fad\\dep-test-bin-NeuralNetwork" - 0.030572800s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: FileTime { seconds: 13424675637, nanos: 17807500 } < FileTime { seconds: 13424675640, nanos: 581835600 } - 0.030859400s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: true }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } - 0.030884100s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleItem(ChangedFile { reference: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-a18b77050cc20fad\\dep-test-bin-NeuralNetwork", reference_mtime: FileTime { seconds: 13424675637, nanos: 17807500 }, stale: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", stale_mtime: FileTime { seconds: 13424675640, nanos: 581835600 } })) + 0.027674900s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: stale: changed "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs" + 0.027743600s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: (vs) "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-9b9040de17136bb0\\dep-bin-NeuralNetwork" + 0.027756200s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: FileTime { seconds: 13424676511, nanos: 602181800 } < FileTime { seconds: 13424676514, nanos: 603411100 } + 0.028053400s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: false }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } + 0.028092400s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleItem(ChangedFile { reference: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-9b9040de17136bb0\\dep-bin-NeuralNetwork", reference_mtime: FileTime { seconds: 13424676511, nanos: 602181800 }, stale: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", stale_mtime: FileTime { seconds: 13424676514, nanos: 603411100 } })) + 0.029227100s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: stale: changed "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs" + 0.029246000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: (vs) "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-a18b77050cc20fad\\dep-test-bin-NeuralNetwork" + 0.029255000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: FileTime { seconds: 13424676511, nanos: 602181800 } < FileTime { seconds: 13424676514, nanos: 603411100 } + 0.029464100s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: true }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } + 0.029486300s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleItem(ChangedFile { reference: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-a18b77050cc20fad\\dep-test-bin-NeuralNetwork", reference_mtime: FileTime { seconds: 13424676511, nanos: 602181800 }, stale: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", stale_mtime: FileTime { seconds: 13424676514, nanos: 603411100 } })) Checking NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) - Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.23s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.25s diff --git a/rust/target/flycheck0/stdout b/rust/target/flycheck0/stdout index e71d0a3..6b305fd 100644 --- a/rust/target/flycheck0/stdout +++ b/rust/target/flycheck0/stdout @@ -1,6 +1,6 @@ {"reason":"compiler-message","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"message":{"$message_type":"diagnostic","message":"crate `NeuralNetwork` should have a snake case name","code":{"code":"non_snake_case","explanation":null},"level":"warning","spans":[{"file_name":"src\\lib.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":true,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"convert the identifier to snake case: `neural_network`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"`#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[93mwarning\u001b[0m\u001b[1m\u001b[97m: crate `NeuralNetwork` should have a snake case name\u001b[0m\n \u001b[1m\u001b[96m|\u001b[0m\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mhelp\u001b[0m: convert the identifier to snake case: `neural_network`\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mnote\u001b[0m: `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default\n\n"}} {"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-b49945cb8e1a061f.rmeta"],"executable":null,"fresh":true} {"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-23b176100197719a.rmeta"],"executable":null,"fresh":true} -{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-a18b77050cc20fad.rmeta"],"executable":null,"fresh":false} {"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-9b9040de17136bb0.rmeta"],"executable":null,"fresh":false} +{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-a18b77050cc20fad.rmeta"],"executable":null,"fresh":false} {"reason":"build-finished","success":true} From 0f9a7ec79b79580718fb6e3085d7262df8dd0d68 Mon Sep 17 00:00:00 2001 From: OtonariS Date: Sun, 31 May 2026 15:45:27 +0900 Subject: [PATCH 4/9] =?UTF-8?q?MatrixLayout=E3=83=88=E3=83=AC=E3=82=A4?= =?UTF-8?q?=E3=83=88=E3=82=92=E5=AE=9F=E8=A3=85=E3=81=97=E3=80=81=E8=A1=8C?= =?UTF-8?q?=E5=88=97=E3=81=AE=E3=82=A4=E3=83=B3=E3=83=87=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=B9=E5=8F=96=E5=BE=97=E3=81=A8=E3=82=B9=E3=83=88=E3=83=A9?= =?UTF-8?q?=E3=82=A4=E3=83=89=E8=A8=88=E7=AE=97=E3=81=AE=E3=83=A1=E3=82=BD?= =?UTF-8?q?=E3=83=83=E3=83=89=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/src/lib.rs | 1 + rust/src/main.rs | 3 +- rust/src/matrix_array.rs | 131 ++++++----------------------------- rust/src/matrix_layout.rs | 56 +++++++++++++++ rust/target/.rustc_info.json | 2 +- rust/target/flycheck0/stderr | 18 ++--- rust/target/flycheck0/stdout | 4 +- 7 files changed, 91 insertions(+), 124 deletions(-) create mode 100644 rust/src/matrix_layout.rs diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 001222a..0d6bae5 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1 +1,2 @@ +pub mod matrix_layout; pub mod matrix_array; \ No newline at end of file diff --git a/rust/src/main.rs b/rust/src/main.rs index f56d4f7..726e9ff 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -1,6 +1,7 @@ use NeuralNetwork::matrix_array; +use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor}; fn main() { - let mtx = matrix_array::MatrixArray::::with_size(3, 4); + let mtx = matrix_array::MatrixArray::::with_size(3, 4); println!("{}", mtx); } \ No newline at end of file diff --git a/rust/src/matrix_array.rs b/rust/src/matrix_array.rs index 6935768..b8af54b 100644 --- a/rust/src/matrix_array.rs +++ b/rust/src/matrix_array.rs @@ -1,12 +1,14 @@ use core::fmt; +use crate::matrix_layout::{ RowMajor, MatrixLayout}; -pub struct MatrixArray { +pub struct MatrixArray { data: Vec, row: usize, col: usize, + _marker: std::marker::PhantomData, } -impl MatrixArray { +impl MatrixArray { pub fn with_size(row: usize, col: usize) -> Self where T: Default + Clone, @@ -15,126 +17,35 @@ impl MatrixArray { data: vec![T::default(); row * col], row, col, - } - } -} - -// ========================================== -// 行優先 (Row-Major) の実装 -// ========================================== -impl MatrixArray { - pub fn with_data(array_2d: [[T; COL]; ROW]) -> Self { - Self { - data: array_2d.into_iter().flatten().collect::>(), - row: ROW, - col: COL, - } - } - - pub fn get(&self, row: usize, col: usize) -> Option<&T> { - if row >= self.row || col >= self.col { return None; } - - let idx = row * self.col + col; - self.data.get(idx) - } - - pub fn get_mut_row(&mut self, row: usize) -> Option> { - if self.row <= row { return None; } - Some(self.data.iter_mut().skip(self.col * row).take(self.col)) - } - pub fn get_mut_column(&mut self, col: usize) -> Option> { - if self.col <= col { return None; } - Some(self.data.iter_mut().skip(col).step_by(self.col).take(self.row)) - } - - pub fn get_row(&self, row: usize) -> Option> { - if self.row <= row { return None; } - Some(self.data.iter().skip(self.col * row).take(self.col)) - } - pub fn get_column(&self, col: usize) -> Option> { - if self.col <= col { return None; } - Some(self.data.iter().skip(col).step_by(self.col).take(self.row)) - } -} - -// ========================================== -// 列優先 (Column-Major) の実装 -// ========================================== -impl MatrixArray { - pub fn with_data(array_2d: [[T; COL]; ROW]) -> Self - where - T: Clone, - { - let array_2d_ref = &array_2d; - let data: Vec = (0..COL) - .flat_map(move |c| (0..ROW).map(move |r| array_2d_ref[r][c].clone())) - .collect(); - - Self { - data, - row: ROW, - col: COL, + _marker: std::marker::PhantomData, } } pub fn get(&self, row: usize, col: usize) -> Option<&T> { - if row >= self.row || col >= self.col { return None; } - - let idx = col * self.row + row; + let idx = L::get_index(row, col, self.row, self.col); self.data.get(idx) } - pub fn get_mut_row(&mut self, row: usize) -> Option> { - if self.row <= row { return None; } - Some(self.data.iter_mut().skip(row).step_by(self.row).take(self.col)) - } - pub fn get_mut_column(&mut self, col: usize) -> Option> { - if self.col <= col { return None; } - Some(self.data.iter_mut().skip(col * self.row).take(self.row)) + pub fn get_row(&self, row: usize) -> impl Iterator { + let (start, step) = L::row_stride(row, self.row, self.col); + self.data.iter().skip(start).step_by(step).take(self.col) } - pub fn get_row(&self, row: usize) -> Option> { - if self.row <= row { return None; } - Some(self.data.iter().skip(row).step_by(self.row).take(self.col)) - } - pub fn get_column(&self, col: usize) -> Option> { - if self.col <= col { return None; } - Some(self.data.iter().skip(col * self.row).take(self.row)) + pub fn get_column(&self, col: usize) -> impl Iterator { + let (start, step) = L::col_stride(col, self.row, self.col); + self.data.iter().skip(start).step_by(step).take(self.row) } } -// ========================================== -// トレイト実装 -// ========================================== -impl fmt::Display for MatrixArray { +impl std::fmt::Display for MatrixArray { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut result = String::new(); - - for r in 0..self.row { - if let Some(row_iter) = self.get_row(r) { - for c in row_iter { - result.push_str(&format!("{}\t", c)); - } - } - result.push('\n'); - } - - write!(f, "{}", result) - } -} -impl fmt::Display for MatrixArray { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut result = String::new(); - - for r in 0..self.row { - if let Some(row_iter) = self.get_row(r) { - for c in row_iter { - result.push_str(&format!("{}\t", c)); - } - } - result.push('\n'); - } - - write!(f, "{}", result) + (0..self.row).for_each(|r| { + self.get_row(r).for_each(|c| { + _ = write!(f, "{}\t", c); + }); + _ = write!(f, "\n"); + }); + + Ok(()) } } \ No newline at end of file diff --git a/rust/src/matrix_layout.rs b/rust/src/matrix_layout.rs new file mode 100644 index 0000000..3b9be6c --- /dev/null +++ b/rust/src/matrix_layout.rs @@ -0,0 +1,56 @@ +pub trait MatrixLayout { + /// row, colから一次元配列のindexを取得する + /// # 引数 + /// - `row`: 行番号 + /// - `col`: 列番号 + /// - `matrix_row`: 行数 + /// - `matrix_col`: 列数 + /// # 戻り値 + /// - 一次元配列のindex + fn get_index(row: usize, col: usize, matrix_row: usize, matrix_col: usize) -> usize; + + /// row, colから行・列のstrideを取得する + /// # 引数 + /// - `row`: 行番号 + /// - `col`: 列番号 + /// - `matrix_row`: 行数 + /// - `matrix_col`: 列数 + /// # 戻り値 + /// - (開始位置, ステップ)のタプル + fn row_stride(row: usize, matrix_row: usize, matrix_col: usize) -> (usize, usize); + + /// row, colから行・列のstrideを取得する + /// # 引数 + /// - `row`: 行番号 + /// - `col`: 列番号 + /// - `matrix_row`: 行数 + /// - `matrix_col`: 列数 + /// # 戻り値 + /// - (開始位置, ステップ)のタプル + fn col_stride(col: usize, matrix_row: usize, matrix_col: usize) -> (usize, usize); +} + +pub struct RowMajor; +impl MatrixLayout for RowMajor { + fn get_index(row: usize, col: usize, _m_row: usize, m_col: usize) -> usize { + row * m_col + col + } + fn row_stride(row: usize, _m_row: usize, m_col: usize) -> (usize, usize) { + (row * m_col, 1) + } + fn col_stride(col: usize, _m_row: usize, m_col: usize) -> (usize, usize) { + (col, m_col) + } +} +pub struct ColumnMajor; +impl MatrixLayout for ColumnMajor { + fn get_index(row: usize, col: usize, m_row: usize, _m_col: usize) -> usize { + col * m_row + row + } + fn row_stride(row: usize, m_row: usize, _m_col: usize) -> (usize, usize) { + (row, m_row) + } + fn col_stride(col: usize, m_row: usize, _m_col: usize) -> (usize, usize) { + (col * m_row, 1) + } +} \ No newline at end of file diff --git a/rust/target/.rustc_info.json b/rust/target/.rustc_info.json index e7ae7f6..992b458 100644 --- a/rust/target/.rustc_info.json +++ b/rust/target/.rustc_info.json @@ -1 +1 @@ -{"rustc_fingerprint":6916924876317518318,"outputs":{"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.95.0 (59807616e 2026-04-14)\nbinary: rustc\ncommit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860\ncommit-date: 2026-04-14\nhost: x86_64-pc-windows-msvc\nrelease: 1.95.0\nLLVM version: 22.1.2\n","stderr":""},"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\sanae\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""}},"successes":{}} \ No newline at end of file +{"rustc_fingerprint":15185187270388882405,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\sanae\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.95.0 (59807616e 2026-04-14)\nbinary: rustc\ncommit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860\ncommit-date: 2026-04-14\nhost: x86_64-pc-windows-msvc\nrelease: 1.95.0\nLLVM version: 22.1.2\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/rust/target/flycheck0/stderr b/rust/target/flycheck0/stderr index 25a7cbe..ec44979 100644 --- a/rust/target/flycheck0/stderr +++ b/rust/target/flycheck0/stderr @@ -1,12 +1,8 @@ - 0.027674900s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: stale: changed "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs" - 0.027743600s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: (vs) "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-9b9040de17136bb0\\dep-bin-NeuralNetwork" - 0.027756200s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: FileTime { seconds: 13424676511, nanos: 602181800 } < FileTime { seconds: 13424676514, nanos: 603411100 } - 0.028053400s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: false }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } - 0.028092400s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleItem(ChangedFile { reference: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-9b9040de17136bb0\\dep-bin-NeuralNetwork", reference_mtime: FileTime { seconds: 13424676511, nanos: 602181800 }, stale: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", stale_mtime: FileTime { seconds: 13424676514, nanos: 603411100 } })) - 0.029227100s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: stale: changed "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs" - 0.029246000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: (vs) "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-a18b77050cc20fad\\dep-test-bin-NeuralNetwork" - 0.029255000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: FileTime { seconds: 13424676511, nanos: 602181800 } < FileTime { seconds: 13424676514, nanos: 603411100 } - 0.029464100s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: true }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } - 0.029486300s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleItem(ChangedFile { reference: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\.fingerprint\\NeuralNetwork-a18b77050cc20fad\\dep-test-bin-NeuralNetwork", reference_mtime: FileTime { seconds: 13424676511, nanos: 602181800 }, stale: "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", stale_mtime: FileTime { seconds: 13424676514, nanos: 603411100 } })) + 0.027104600s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dependency on `NeuralNetwork` is newer than we are 13424683378.301739700s > 13424679492.143528100s "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust" + 0.027417000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: false }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } + 0.027454700s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleDependency { unit: UnitIndex(0), dep_mtime: FileTime { seconds: 13424683378, nanos: 301739700 }, max_mtime: FileTime { seconds: 13424679492, nanos: 143528100 } }) + 0.028619100s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dependency on `NeuralNetwork` is newer than we are 13424683378.301739700s > 13424679492.143528100s "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust" + 0.028888000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: true }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } + 0.028911200s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleDependency { unit: UnitIndex(0), dep_mtime: FileTime { seconds: 13424683378, nanos: 301739700 }, max_mtime: FileTime { seconds: 13424679492, nanos: 143528100 } }) Checking NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) - Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.25s + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.24s diff --git a/rust/target/flycheck0/stdout b/rust/target/flycheck0/stdout index 6b305fd..0468d3a 100644 --- a/rust/target/flycheck0/stdout +++ b/rust/target/flycheck0/stdout @@ -1,6 +1,8 @@ {"reason":"compiler-message","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"message":{"$message_type":"diagnostic","message":"crate `NeuralNetwork` should have a snake case name","code":{"code":"non_snake_case","explanation":null},"level":"warning","spans":[{"file_name":"src\\lib.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":true,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"convert the identifier to snake case: `neural_network`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"`#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[93mwarning\u001b[0m\u001b[1m\u001b[97m: crate `NeuralNetwork` should have a snake case name\u001b[0m\n \u001b[1m\u001b[96m|\u001b[0m\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mhelp\u001b[0m: convert the identifier to snake case: `neural_network`\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mnote\u001b[0m: `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default\n\n"}} {"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-b49945cb8e1a061f.rmeta"],"executable":null,"fresh":true} {"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-23b176100197719a.rmeta"],"executable":null,"fresh":true} -{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-9b9040de17136bb0.rmeta"],"executable":null,"fresh":false} +{"reason":"compiler-message","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"message":{"$message_type":"diagnostic","message":"unused import: `ColumnMajor`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"src\\main.rs","byte_start":69,"byte_end":80,"line_start":2,"line_end":2,"column_start":36,"column_end":47,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":36,"highlight_end":47}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove the unused import","code":null,"level":"help","spans":[{"file_name":"src\\main.rs","byte_start":69,"byte_end":82,"line_start":2,"line_end":2,"column_start":36,"column_end":49,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":36,"highlight_end":49}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null},{"file_name":"src\\main.rs","byte_start":68,"byte_end":69,"line_start":2,"line_end":2,"column_start":35,"column_end":36,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":35,"highlight_end":36}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null},{"file_name":"src\\main.rs","byte_start":90,"byte_end":91,"line_start":2,"line_end":2,"column_start":57,"column_end":58,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":57,"highlight_end":58}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[93mwarning\u001b[0m\u001b[1m\u001b[97m: unused import: `ColumnMajor`\u001b[0m\n \u001b[1m\u001b[96m--> \u001b[0msrc\\main.rs:2:36\n \u001b[1m\u001b[96m|\u001b[0m\n\u001b[1m\u001b[96m2\u001b[0m \u001b[1m\u001b[96m|\u001b[0m use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};\n \u001b[1m\u001b[96m|\u001b[0m \u001b[1m\u001b[93m^^^^^^^^^^^\u001b[0m\n \u001b[1m\u001b[96m|\u001b[0m\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mnote\u001b[0m: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default\n\n"}} +{"reason":"compiler-message","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"message":{"$message_type":"diagnostic","message":"unused import: `ColumnMajor`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"src\\main.rs","byte_start":69,"byte_end":80,"line_start":2,"line_end":2,"column_start":36,"column_end":47,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":36,"highlight_end":47}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove the unused import","code":null,"level":"help","spans":[{"file_name":"src\\main.rs","byte_start":69,"byte_end":82,"line_start":2,"line_end":2,"column_start":36,"column_end":49,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":36,"highlight_end":49}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null},{"file_name":"src\\main.rs","byte_start":68,"byte_end":69,"line_start":2,"line_end":2,"column_start":35,"column_end":36,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":35,"highlight_end":36}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null},{"file_name":"src\\main.rs","byte_start":90,"byte_end":91,"line_start":2,"line_end":2,"column_start":57,"column_end":58,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":57,"highlight_end":58}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[93mwarning\u001b[0m\u001b[1m\u001b[97m: unused import: `ColumnMajor`\u001b[0m\n \u001b[1m\u001b[96m--> \u001b[0msrc\\main.rs:2:36\n \u001b[1m\u001b[96m|\u001b[0m\n\u001b[1m\u001b[96m2\u001b[0m \u001b[1m\u001b[96m|\u001b[0m use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};\n \u001b[1m\u001b[96m|\u001b[0m \u001b[1m\u001b[93m^^^^^^^^^^^\u001b[0m\n \u001b[1m\u001b[96m|\u001b[0m\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mnote\u001b[0m: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default\n\n"}} {"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-a18b77050cc20fad.rmeta"],"executable":null,"fresh":false} +{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-9b9040de17136bb0.rmeta"],"executable":null,"fresh":false} {"reason":"build-finished","success":true} From e5d3720a18424a50612553d47bd1f7e4a9c1ee44 Mon Sep 17 00:00:00 2001 From: OtonariS Date: Sun, 31 May 2026 16:10:39 +0900 Subject: [PATCH 5/9] =?UTF-8?q?.gitignore=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=80=81target?= =?UTF-8?q?=E3=83=87=E3=82=A3=E3=83=AC=E3=82=AF=E3=83=88=E3=83=AA=E3=82=92?= =?UTF-8?q?=E7=84=A1=E8=A6=96=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=80=82=E4=B8=8D=E8=A6=81=E3=81=AA=E3=82=BF?= =?UTF-8?q?=E3=83=BC=E3=82=B2=E3=83=83=E3=83=88=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=82=92=E5=89=8A=E9=99=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/.gitignore | 1 + rust/target/.rustc_info.json | 1 - rust/target/CACHEDIR.TAG | 3 --- rust/target/flycheck0/stderr | 8 -------- rust/target/flycheck0/stdout | 8 -------- 5 files changed, 1 insertion(+), 20 deletions(-) create mode 100644 rust/.gitignore delete mode 100644 rust/target/.rustc_info.json delete mode 100644 rust/target/CACHEDIR.TAG delete mode 100644 rust/target/flycheck0/stderr delete mode 100644 rust/target/flycheck0/stdout diff --git a/rust/.gitignore b/rust/.gitignore new file mode 100644 index 0000000..9f97022 --- /dev/null +++ b/rust/.gitignore @@ -0,0 +1 @@ +target/ \ No newline at end of file diff --git a/rust/target/.rustc_info.json b/rust/target/.rustc_info.json deleted file mode 100644 index 992b458..0000000 --- a/rust/target/.rustc_info.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc_fingerprint":15185187270388882405,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\sanae\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.95.0 (59807616e 2026-04-14)\nbinary: rustc\ncommit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860\ncommit-date: 2026-04-14\nhost: x86_64-pc-windows-msvc\nrelease: 1.95.0\nLLVM version: 22.1.2\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/rust/target/CACHEDIR.TAG b/rust/target/CACHEDIR.TAG deleted file mode 100644 index 20d7c31..0000000 --- a/rust/target/CACHEDIR.TAG +++ /dev/null @@ -1,3 +0,0 @@ -Signature: 8a477f597d28d172789f06886806bc55 -# This file is a cache directory tag created by cargo. -# For information about cache directory tags see https://bford.info/cachedir/ diff --git a/rust/target/flycheck0/stderr b/rust/target/flycheck0/stderr deleted file mode 100644 index ec44979..0000000 --- a/rust/target/flycheck0/stderr +++ /dev/null @@ -1,8 +0,0 @@ - 0.027104600s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dependency on `NeuralNetwork` is newer than we are 13424683378.301739700s > 13424679492.143528100s "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust" - 0.027417000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: false }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } - 0.027454700s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleDependency { unit: UnitIndex(0), dep_mtime: FileTime { seconds: 13424683378, nanos: 301739700 }, max_mtime: FileTime { seconds: 13424679492, nanos: 143528100 } }) - 0.028619100s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dependency on `NeuralNetwork` is newer than we are 13424683378.301739700s > 13424679492.143528100s "C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust" - 0.028888000s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: fingerprint dirty for NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust)/Check { test: true }/TargetInner { name: "NeuralNetwork", doc: true, ..: with_path("C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs", Edition2024) } - 0.028911200s INFO prepare_target{force=false package_id=NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) target="NeuralNetwork"}: cargo::core::compiler::fingerprint: dirty: FsStatusOutdated(StaleDependency { unit: UnitIndex(0), dep_mtime: FileTime { seconds: 13424683378, nanos: 301739700 }, max_mtime: FileTime { seconds: 13424679492, nanos: 143528100 } }) - Checking NeuralNetwork v0.1.0 (C:\Users\sanae\Desktop\NeuralNetwork\rust) - Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.24s diff --git a/rust/target/flycheck0/stdout b/rust/target/flycheck0/stdout deleted file mode 100644 index 0468d3a..0000000 --- a/rust/target/flycheck0/stdout +++ /dev/null @@ -1,8 +0,0 @@ -{"reason":"compiler-message","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"message":{"$message_type":"diagnostic","message":"crate `NeuralNetwork` should have a snake case name","code":{"code":"non_snake_case","explanation":null},"level":"warning","spans":[{"file_name":"src\\lib.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":true,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"convert the identifier to snake case: `neural_network`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"`#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[93mwarning\u001b[0m\u001b[1m\u001b[97m: crate `NeuralNetwork` should have a snake case name\u001b[0m\n \u001b[1m\u001b[96m|\u001b[0m\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mhelp\u001b[0m: convert the identifier to snake case: `neural_network`\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mnote\u001b[0m: `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default\n\n"}} -{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-b49945cb8e1a061f.rmeta"],"executable":null,"fresh":true} -{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\lib.rs","edition":"2024","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-23b176100197719a.rmeta"],"executable":null,"fresh":true} -{"reason":"compiler-message","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"message":{"$message_type":"diagnostic","message":"unused import: `ColumnMajor`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"src\\main.rs","byte_start":69,"byte_end":80,"line_start":2,"line_end":2,"column_start":36,"column_end":47,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":36,"highlight_end":47}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove the unused import","code":null,"level":"help","spans":[{"file_name":"src\\main.rs","byte_start":69,"byte_end":82,"line_start":2,"line_end":2,"column_start":36,"column_end":49,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":36,"highlight_end":49}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null},{"file_name":"src\\main.rs","byte_start":68,"byte_end":69,"line_start":2,"line_end":2,"column_start":35,"column_end":36,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":35,"highlight_end":36}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null},{"file_name":"src\\main.rs","byte_start":90,"byte_end":91,"line_start":2,"line_end":2,"column_start":57,"column_end":58,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":57,"highlight_end":58}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[93mwarning\u001b[0m\u001b[1m\u001b[97m: unused import: `ColumnMajor`\u001b[0m\n \u001b[1m\u001b[96m--> \u001b[0msrc\\main.rs:2:36\n \u001b[1m\u001b[96m|\u001b[0m\n\u001b[1m\u001b[96m2\u001b[0m \u001b[1m\u001b[96m|\u001b[0m use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};\n \u001b[1m\u001b[96m|\u001b[0m \u001b[1m\u001b[93m^^^^^^^^^^^\u001b[0m\n \u001b[1m\u001b[96m|\u001b[0m\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mnote\u001b[0m: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default\n\n"}} -{"reason":"compiler-message","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"message":{"$message_type":"diagnostic","message":"unused import: `ColumnMajor`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"src\\main.rs","byte_start":69,"byte_end":80,"line_start":2,"line_end":2,"column_start":36,"column_end":47,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":36,"highlight_end":47}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove the unused import","code":null,"level":"help","spans":[{"file_name":"src\\main.rs","byte_start":69,"byte_end":82,"line_start":2,"line_end":2,"column_start":36,"column_end":49,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":36,"highlight_end":49}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null},{"file_name":"src\\main.rs","byte_start":68,"byte_end":69,"line_start":2,"line_end":2,"column_start":35,"column_end":36,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":35,"highlight_end":36}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null},{"file_name":"src\\main.rs","byte_start":90,"byte_end":91,"line_start":2,"line_end":2,"column_start":57,"column_end":58,"is_primary":true,"text":[{"text":"use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};","highlight_start":57,"highlight_end":58}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[93mwarning\u001b[0m\u001b[1m\u001b[97m: unused import: `ColumnMajor`\u001b[0m\n \u001b[1m\u001b[96m--> \u001b[0msrc\\main.rs:2:36\n \u001b[1m\u001b[96m|\u001b[0m\n\u001b[1m\u001b[96m2\u001b[0m \u001b[1m\u001b[96m|\u001b[0m use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor};\n \u001b[1m\u001b[96m|\u001b[0m \u001b[1m\u001b[93m^^^^^^^^^^^\u001b[0m\n \u001b[1m\u001b[96m|\u001b[0m\n \u001b[1m\u001b[96m= \u001b[0m\u001b[1m\u001b[97mnote\u001b[0m: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default\n\n"}} -{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":true},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-a18b77050cc20fad.rmeta"],"executable":null,"fresh":false} -{"reason":"compiler-artifact","package_id":"path+file:///C:/Users/sanae/Desktop/NeuralNetwork/rust#NeuralNetwork@0.1.0","manifest_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"NeuralNetwork","src_path":"C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\src\\main.rs","edition":"2024","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\sanae\\Desktop\\NeuralNetwork\\rust\\target\\debug\\deps\\libNeuralNetwork-9b9040de17136bb0.rmeta"],"executable":null,"fresh":false} -{"reason":"build-finished","success":true} From 24637020f4e3ce1b6b5b7750426b829b94e7f096 Mon Sep 17 00:00:00 2001 From: OtonariS Date: Sun, 31 May 2026 16:10:51 +0900 Subject: [PATCH 6/9] =?UTF-8?q?.gitignore=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AEtarget=E3=83=87=E3=82=A3=E3=83=AC=E3=82=AF?= =?UTF-8?q?=E3=83=88=E3=83=AA=E8=A8=AD=E5=AE=9A=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/.gitignore b/rust/.gitignore index 9f97022..1de5659 100644 --- a/rust/.gitignore +++ b/rust/.gitignore @@ -1 +1 @@ -target/ \ No newline at end of file +target \ No newline at end of file From 562ebff57eef6e4c35415a299a358a12d76bdb05 Mon Sep 17 00:00:00 2001 From: OtonariS Date: Sun, 31 May 2026 16:12:20 +0900 Subject: [PATCH 7/9] =?UTF-8?q?MatrixLayout=E3=83=88=E3=83=AC=E3=82=A4?= =?UTF-8?q?=E3=83=88=E3=81=AE=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=81=8B?= =?UTF-8?q?=E3=82=89=E4=B8=8D=E8=A6=81=E3=81=AA=E5=BC=95=E6=95=B0=E8=AA=AC?= =?UTF-8?q?=E6=98=8E=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/src/matrix_layout.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/rust/src/matrix_layout.rs b/rust/src/matrix_layout.rs index 3b9be6c..7ba1e68 100644 --- a/rust/src/matrix_layout.rs +++ b/rust/src/matrix_layout.rs @@ -12,7 +12,6 @@ pub trait MatrixLayout { /// row, colから行・列のstrideを取得する /// # 引数 /// - `row`: 行番号 - /// - `col`: 列番号 /// - `matrix_row`: 行数 /// - `matrix_col`: 列数 /// # 戻り値 @@ -21,7 +20,6 @@ pub trait MatrixLayout { /// row, colから行・列のstrideを取得する /// # 引数 - /// - `row`: 行番号 /// - `col`: 列番号 /// - `matrix_row`: 行数 /// - `matrix_col`: 列数 From 7256351e83d4be922d42338e55466382f58b9079 Mon Sep 17 00:00:00 2001 From: OtonariS Date: Sun, 31 May 2026 16:36:16 +0900 Subject: [PATCH 8/9] =?UTF-8?q?MatrixArray=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=82=92=E5=89=8A=E9=99=A4=E3=81=97=E3=80=81?= =?UTF-8?q?Matrix=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=A6=E8=A1=8C=E5=88=97=E3=81=AE?= =?UTF-8?q?=E5=AE=9F=E8=A3=85=E3=82=92=E7=B5=B1=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/src/lib.rs | 2 +- rust/src/main.rs | 4 ++-- rust/src/{matrix_array.rs => matrix.rs} | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) rename rust/src/{matrix_array.rs => matrix.rs} (88%) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 0d6bae5..3489657 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,2 +1,2 @@ pub mod matrix_layout; -pub mod matrix_array; \ No newline at end of file +pub mod matrix; \ No newline at end of file diff --git a/rust/src/main.rs b/rust/src/main.rs index 726e9ff..93c124a 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -1,7 +1,7 @@ -use NeuralNetwork::matrix_array; +use NeuralNetwork::matrix; use NeuralNetwork::matrix_layout::{ColumnMajor, RowMajor}; fn main() { - let mtx = matrix_array::MatrixArray::::with_size(3, 4); + let mtx = matrix::Matrix::::with_size(3, 4); println!("{}", mtx); } \ No newline at end of file diff --git a/rust/src/matrix_array.rs b/rust/src/matrix.rs similarity index 88% rename from rust/src/matrix_array.rs rename to rust/src/matrix.rs index b8af54b..097729e 100644 --- a/rust/src/matrix_array.rs +++ b/rust/src/matrix.rs @@ -1,14 +1,14 @@ use core::fmt; use crate::matrix_layout::{ RowMajor, MatrixLayout}; -pub struct MatrixArray { +pub struct Matrix { data: Vec, row: usize, col: usize, _marker: std::marker::PhantomData, } -impl MatrixArray { +impl Matrix { pub fn with_size(row: usize, col: usize) -> Self where T: Default + Clone, @@ -22,6 +22,8 @@ impl MatrixArray { } pub fn get(&self, row: usize, col: usize) -> Option<&T> { + if row >= self.row || col >= self.col { return None; } + let idx = L::get_index(row, col, self.row, self.col); self.data.get(idx) } @@ -37,7 +39,7 @@ impl MatrixArray { } } -impl std::fmt::Display for MatrixArray { +impl std::fmt::Display for Matrix { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (0..self.row).for_each(|r| { self.get_row(r).for_each(|c| { From f85669b2a9ec239fb7201365c4844ad61ec421fc Mon Sep 17 00:00:00 2001 From: OtonariS Date: Mon, 1 Jun 2026 10:14:39 +0900 Subject: [PATCH 9/9] =?UTF-8?q?MatrixLayout=E3=83=88=E3=83=AC=E3=82=A4?= =?UTF-8?q?=E3=83=88=E3=81=AE=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92?= =?UTF-8?q?Option=E5=9E=8B=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97=E3=80=81?= =?UTF-8?q?=E8=A1=8C=E5=88=97=E3=81=AE=E3=82=A4=E3=83=B3=E3=83=87=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=82=B9=E5=8F=96=E5=BE=97=E3=81=A8=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=89=E8=A8=88=E7=AE=97=E3=81=A7=E3=81=AE?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=8F=E3=83=B3=E3=83=89=E3=83=AA?= =?UTF-8?q?=E3=83=B3=E3=82=B0=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/src/matrix.rs | 22 +++++++++-------- rust/src/matrix_layout.rs | 51 +++++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/rust/src/matrix.rs b/rust/src/matrix.rs index 097729e..43bb9d6 100644 --- a/rust/src/matrix.rs +++ b/rust/src/matrix.rs @@ -24,27 +24,29 @@ impl Matrix { pub fn get(&self, row: usize, col: usize) -> Option<&T> { if row >= self.row || col >= self.col { return None; } - let idx = L::get_index(row, col, self.row, self.col); + let idx = L::get_index(row, col, self.row, self.col)?; self.data.get(idx) } - pub fn get_row(&self, row: usize) -> impl Iterator { - let (start, step) = L::row_stride(row, self.row, self.col); - self.data.iter().skip(start).step_by(step).take(self.col) + pub fn get_row(&self, row: usize) -> Option> { + let (start, step) = L::row_stride(row, self.row, self.col)?; + Some(self.data.iter().skip(start).step_by(step).take(self.col)) } - pub fn get_column(&self, col: usize) -> impl Iterator { - let (start, step) = L::col_stride(col, self.row, self.col); - self.data.iter().skip(start).step_by(step).take(self.row) + pub fn get_column(&self, col: usize) -> Option> { + let (start, step) = L::col_stride(col, self.row, self.col)?; + Some(self.data.iter().skip(start).step_by(step).take(self.row)) } } impl std::fmt::Display for Matrix { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (0..self.row).for_each(|r| { - self.get_row(r).for_each(|c| { - _ = write!(f, "{}\t", c); - }); + if let Some(row_iter) = self.get_row(r) { + row_iter.for_each(|c| { + _ = write!(f, "{}\t", c); + }); + } _ = write!(f, "\n"); }); diff --git a/rust/src/matrix_layout.rs b/rust/src/matrix_layout.rs index 7ba1e68..0678a2b 100644 --- a/rust/src/matrix_layout.rs +++ b/rust/src/matrix_layout.rs @@ -7,7 +7,7 @@ pub trait MatrixLayout { /// - `matrix_col`: 列数 /// # 戻り値 /// - 一次元配列のindex - fn get_index(row: usize, col: usize, matrix_row: usize, matrix_col: usize) -> usize; + fn get_index(row: usize, col: usize, matrix_row: usize, matrix_col: usize) -> Option; /// row, colから行・列のstrideを取得する /// # 引数 @@ -16,7 +16,7 @@ pub trait MatrixLayout { /// - `matrix_col`: 列数 /// # 戻り値 /// - (開始位置, ステップ)のタプル - fn row_stride(row: usize, matrix_row: usize, matrix_col: usize) -> (usize, usize); + fn row_stride(row: usize, matrix_row: usize, matrix_col: usize) -> Option<(usize, usize)>; /// row, colから行・列のstrideを取得する /// # 引数 @@ -25,30 +25,51 @@ pub trait MatrixLayout { /// - `matrix_col`: 列数 /// # 戻り値 /// - (開始位置, ステップ)のタプル - fn col_stride(col: usize, matrix_row: usize, matrix_col: usize) -> (usize, usize); + fn col_stride(col: usize, matrix_row: usize, matrix_col: usize) -> Option<(usize, usize)>; } pub struct RowMajor; impl MatrixLayout for RowMajor { - fn get_index(row: usize, col: usize, _m_row: usize, m_col: usize) -> usize { - row * m_col + col + fn get_index(row: usize, col: usize, _m_row: usize, m_col: usize) -> Option { + if _m_row == 0 || m_col == 0 || row >= _m_row || col >= m_col { + return None; + } + + Some(row * m_col + col) } - fn row_stride(row: usize, _m_row: usize, m_col: usize) -> (usize, usize) { - (row * m_col, 1) + fn row_stride(row: usize, _m_row: usize, m_col: usize) -> Option<(usize, usize)> { + if _m_row == 0 || m_col == 0 || row >= _m_row { + return None; + } + + Some((row * m_col, 1)) } - fn col_stride(col: usize, _m_row: usize, m_col: usize) -> (usize, usize) { - (col, m_col) + fn col_stride(col: usize, _m_row: usize, m_col: usize) -> Option<(usize, usize)> { + if _m_row == 0 || m_col == 0 || col >= m_col { + return None; + } + + Some((col, m_col)) } } pub struct ColumnMajor; impl MatrixLayout for ColumnMajor { - fn get_index(row: usize, col: usize, m_row: usize, _m_col: usize) -> usize { - col * m_row + row + fn get_index(row: usize, col: usize, m_row: usize, _m_col: usize) -> Option { + if m_row == 0 || _m_col == 0 || row >= m_row || col >= _m_col { + return None; + } + Some(col * m_row + row) } - fn row_stride(row: usize, m_row: usize, _m_col: usize) -> (usize, usize) { - (row, m_row) + fn row_stride(row: usize, m_row: usize, _m_col: usize) -> Option<(usize, usize)> { + if m_row == 0 || _m_col == 0 || row >= m_row { + return None; + } + Some((row, m_row)) } - fn col_stride(col: usize, m_row: usize, _m_col: usize) -> (usize, usize) { - (col * m_row, 1) + fn col_stride(col: usize, m_row: usize, _m_col: usize) -> Option<(usize, usize)> { + if m_row == 0 || _m_col == 0 || col >= _m_col { + return None; + } + Some((col * m_row, 1)) } } \ No newline at end of file