1
1
<!DOCTYPE html> < html lang ="en "> < head > < meta charset ="utf-8 "> < meta name ="viewport " content ="width=device-width, initial-scale=1.0 "> < meta name ="generator " content ="rustdoc "> < meta name ="description " content ="Return the dot product of two arrays. "> < title > dot_bound in numpy - Rust</ title > < link rel ="preload " as ="font " type ="font/woff2 " crossorigin href ="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2 "> < link rel ="preload " as ="font " type ="font/woff2 " crossorigin href ="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2 "> < link rel ="preload " as ="font " type ="font/woff2 " crossorigin href ="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2 "> < link rel ="preload " as ="font " type ="font/woff2 " crossorigin href ="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2 "> < link rel ="preload " as ="font " type ="font/woff2 " crossorigin href ="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2 "> < link rel ="stylesheet " href ="../static.files/normalize-76eba96aa4d2e634.css "> < link rel ="stylesheet " href ="../static.files/rustdoc-5bc39a1768837dd0.css "> < meta name ="rustdoc-vars " data-root-path ="../ " data-static-root-path ="../static.files/ " data-current-crate ="numpy " data-themes ="" data-resource-suffix ="" data-rustdoc-version ="1.77.0 (aedd173a2 2024-03-17) " data-channel ="1.77.0 " data-search-js ="search-dd67cee4cfa65049.js " data-settings-js ="settings-4313503d2e1961c2.js " > < script src ="../static.files/storage-4c98445ec4002617.js "> </ script > < script defer src ="sidebar-items.js "> </ script > < script defer src ="../static.files/main-48f368f3872407c8.js "> </ script > < noscript > < link rel ="stylesheet " href ="../static.files/noscript-04d5337699b92874.css "> </ noscript > < link rel ="alternate icon " type ="image/png " href ="../static.files/favicon-16x16-8b506e7a72182f1c.png "> < link rel ="alternate icon " type ="image/png " href ="../static.files/favicon-32x32-422f7d1d52889060.png "> < link rel ="icon " type ="image/svg+xml " href ="../static.files/favicon-2c020d218678b618.svg "> </ head > < body class ="rustdoc fn "> <!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--> < nav class ="mobile-topbar "> < button class ="sidebar-menu-toggle " title ="show sidebar "> </ button > </ nav > < nav class ="sidebar "> < div class ="sidebar-crate "> < h2 > < a href ="../numpy/index.html "> numpy</ a > < span class ="version "> 0.20.0</ span > </ h2 > </ div > < div class ="sidebar-elems "> </ div > </ nav > < div class ="sidebar-resizer "> </ div >
2
- < main > < div class ="width-limiter "> < nav class ="sub "> < form class ="search-form "> < span > </ span > < div id ="sidebar-button " tabindex ="-1 "> < a href ="../numpy/all.html " title ="show sidebar "> </ a > </ div > < input class ="search-input " name ="search " aria-label ="Run search in the documentation " autocomplete ="off " spellcheck ="false " placeholder ="Click or press ‘S’ to search, ‘?’ for more options… " type ="search "> < div id ="help-button " tabindex ="-1 "> < a href ="../help.html " title ="help "> ?</ a > </ div > < div id ="settings-menu " tabindex ="-1 "> < a href ="../settings.html " title ="settings "> < img width ="22 " height ="22 " alt ="Change settings " src ="../static.files/wheel-7b819b6101059cd0.svg "> </ a > </ div > </ form > </ nav > < section id ="main-content " class ="content "> < div class ="main-heading "> < h1 > Function < a href ="index.html "> numpy</ a > ::< wbr > < a class ="fn " href ="# "> dot_bound</ a > < button id ="copy-path " title ="Copy item path to clipboard "> < img src ="../static.files/clipboard-7571035ce49a181d.svg " width ="19 " height ="18 " alt ="Copy item path "> </ button > </ h1 > < span class ="out-of-band "> < a class ="src " href ="../src/numpy/sum_products.rs.html#159-175 "> source</ a > · < button id ="toggle-all-docs " title ="collapse all docs "> [< span > −</ span > ]</ button > </ span > </ div > < pre class ="rust item-decl "> < code > pub fn dot_bound<'py, T, DIN1, DIN2, OUT>(
2
+ < main > < div class ="width-limiter "> < nav class ="sub "> < form class ="search-form "> < span > </ span > < div id ="sidebar-button " tabindex ="-1 "> < a href ="../numpy/all.html " title ="show sidebar "> </ a > </ div > < input class ="search-input " name ="search " aria-label ="Run search in the documentation " autocomplete ="off " spellcheck ="false " placeholder ="Click or press ‘S’ to search, ‘?’ for more options… " type ="search "> < div id ="help-button " tabindex ="-1 "> < a href ="../help.html " title ="help "> ?</ a > </ div > < div id ="settings-menu " tabindex ="-1 "> < a href ="../settings.html " title ="settings "> < img width ="22 " height ="22 " alt ="Change settings " src ="../static.files/wheel-7b819b6101059cd0.svg "> </ a > </ div > </ form > </ nav > < section id ="main-content " class ="content "> < div class ="main-heading "> < h1 > Function < a href ="index.html "> numpy</ a > ::< wbr > < a class ="fn " href ="# "> dot_bound</ a > < button id ="copy-path " title ="Copy item path to clipboard "> < img src ="../static.files/clipboard-7571035ce49a181d.svg " width ="19 " height ="18 " alt ="Copy item path "> </ button > </ h1 > < span class ="out-of-band "> < a class ="src " href ="../src/numpy/sum_products.rs.html#160-176 "> source</ a > · < button id ="toggle-all-docs " title ="collapse all docs "> [< span > −</ span > ]</ button > </ span > </ div > < pre class ="rust item-decl "> < code > pub fn dot_bound<'py, T, DIN1, DIN2, OUT>(
3
3
array1: &Bound<'py, < a class ="struct " href ="array/struct.PyArray.html " title ="struct numpy::array::PyArray "> PyArray</ a > <T, DIN1>>,
4
4
array2: &Bound<'py, < a class ="struct " href ="array/struct.PyArray.html " title ="struct numpy::array::PyArray "> PyArray</ a > <T, DIN2>>
5
5
) -> PyResult<OUT>< div class ="where "> where
11
11
< h2 id ="examples "> < a class ="doc-anchor " href ="#examples "> §</ a > Examples</ h2 >
12
12
< p > Note that this function can either return an array…</ p >
13
13
14
- < div class ="example-wrap "> < pre class ="rust rust-example-rendered "> < code > < span class ="kw "> use </ span > pyo3::{Python, Bound, PyNativeType };
14
+ < div class ="example-wrap "> < pre class ="rust rust-example-rendered "> < code > < span class ="kw "> use </ span > pyo3::{Python, Bound};
15
15
< span class ="kw "> use </ span > ndarray::array;
16
- < span class ="kw "> use </ span > numpy::{dot_bound, pyarray , PyArray2, PyArrayMethods};
16
+ < span class ="kw "> use </ span > numpy::{dot_bound, pyarray_bound , PyArray2, PyArrayMethods};
17
17
18
18
Python::with_gil(|py| {
19
- < span class ="kw "> let </ span > matrix = < span class ="macro "> pyarray !</ span > [py, [< span class ="number "> 1</ span > , < span class ="number "> 0</ span > ], [< span class ="number "> 0</ span > , < span class ="number "> 1</ span > ]].as_borrowed() ;
20
- < span class ="kw "> let </ span > another_matrix = < span class ="macro "> pyarray !</ span > [py, [< span class ="number "> 4</ span > , < span class ="number "> 1</ span > ], [< span class ="number "> 2</ span > , < span class ="number "> 2</ span > ]].as_borrowed() ;
19
+ < span class ="kw "> let </ span > matrix = < span class ="macro "> pyarray_bound !</ span > [py, [< span class ="number "> 1</ span > , < span class ="number "> 0</ span > ], [< span class ="number "> 0</ span > , < span class ="number "> 1</ span > ]];
20
+ < span class ="kw "> let </ span > another_matrix = < span class ="macro "> pyarray_bound !</ span > [py, [< span class ="number "> 4</ span > , < span class ="number "> 1</ span > ], [< span class ="number "> 2</ span > , < span class ="number "> 2</ span > ]];
21
21
22
22
< span class ="kw "> let </ span > result: Bound<< span class ="lifetime "> '_</ span > , PyArray2<< span class ="kw "> _</ span > >> = dot_bound(< span class ="kw-2 "> &</ span > matrix, < span class ="kw-2 "> &</ span > another_matrix).unwrap();
23
23
@@ -28,11 +28,11 @@ <h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
28
28
});</ code > </ pre > </ div >
29
29
< p > …or a scalar depending on its arguments.</ p >
30
30
31
- < div class ="example-wrap "> < pre class ="rust rust-example-rendered "> < code > < span class ="kw "> use </ span > pyo3::{ Python, PyNativeType} ;
32
- < span class ="kw "> use </ span > numpy::{dot_bound, pyarray , PyArray0};
31
+ < div class ="example-wrap "> < pre class ="rust rust-example-rendered "> < code > < span class ="kw "> use </ span > pyo3::Python;
32
+ < span class ="kw "> use </ span > numpy::{dot_bound, pyarray_bound , PyArray0};
33
33
34
34
Python::with_gil(|py| {
35
- < span class ="kw "> let </ span > vector = < span class ="macro "> pyarray !</ span > [py, < span class ="number "> 1.0</ span > , < span class ="number "> 2.0</ span > , < span class ="number "> 3.0</ span > ].as_borrowed() ;
35
+ < span class ="kw "> let </ span > vector = < span class ="macro "> pyarray_bound !</ span > [py, < span class ="number "> 1.0</ span > , < span class ="number "> 2.0</ span > , < span class ="number "> 3.0</ span > ];
36
36
< span class ="kw "> let </ span > result: f64 = dot_bound(< span class ="kw-2 "> &</ span > vector, < span class ="kw-2 "> &</ span > vector).unwrap();
37
37
< span class ="macro "> assert_eq!</ span > (result, < span class ="number "> 14.0</ span > );
38
38
});</ code > </ pre > </ div >
0 commit comments