From d9183419b8b8f7a3baec85fd1565ec1cabc439f7 Mon Sep 17 00:00:00 2001 From: Dorival Pedroso Date: Fri, 19 Apr 2024 08:46:36 +1000 Subject: [PATCH 1/3] Rename example --- russell_lab/examples/{mat_cholesky.rs => matrix_cholesky_3x3.rs} | 0 .../examples/{matrix_cholesky.rs => matrix_cholesky_4x4.rs} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename russell_lab/examples/{mat_cholesky.rs => matrix_cholesky_3x3.rs} (100%) rename russell_lab/examples/{matrix_cholesky.rs => matrix_cholesky_4x4.rs} (100%) diff --git a/russell_lab/examples/mat_cholesky.rs b/russell_lab/examples/matrix_cholesky_3x3.rs similarity index 100% rename from russell_lab/examples/mat_cholesky.rs rename to russell_lab/examples/matrix_cholesky_3x3.rs diff --git a/russell_lab/examples/matrix_cholesky.rs b/russell_lab/examples/matrix_cholesky_4x4.rs similarity index 100% rename from russell_lab/examples/matrix_cholesky.rs rename to russell_lab/examples/matrix_cholesky_4x4.rs From 553a76662309b9636d14869ed3202878120e8f62 Mon Sep 17 00:00:00 2001 From: Dorival Pedroso Date: Fri, 19 Apr 2024 09:04:11 +1000 Subject: [PATCH 2/3] Improve examples (vector) --- russell_lab/examples/vector_axpy_and_sum.rs | 21 +++++++++++++++++++ .../examples/vector_dot_scale_and_copy.rs | 14 +++++++++++++ russell_lab/examples/vector_norms.rs | 6 ++++++ 3 files changed, 41 insertions(+) diff --git a/russell_lab/examples/vector_axpy_and_sum.rs b/russell_lab/examples/vector_axpy_and_sum.rs index 66f1dfbb..0f1fa314 100644 --- a/russell_lab/examples/vector_axpy_and_sum.rs +++ b/russell_lab/examples/vector_axpy_and_sum.rs @@ -1,5 +1,26 @@ use russell_lab::*; fn main() -> Result<(), StrError> { + // axpy + let u = Vector::from(&[10.0, 20.0, 30.0]); + let mut v = Vector::from(&[10.0, 20.0, 30.0]); + vec_update(&mut v, 0.1, &u)?; + let correct = "┌ ┐\n\ + │ 11 │\n\ + │ 22 │\n\ + │ 33 │\n\ + └ ┘"; + assert_eq!(format!("{}", v), correct); + + // sum + let w = Vector::filled(3, 1.0); + let mut z = Vector::new(3); + vec_add(&mut z, 1.0, &v, 100.0, &w)?; + let correct = "┌ ┐\n\ + │ 111 │\n\ + │ 122 │\n\ + │ 133 │\n\ + └ ┘"; + assert_eq!(format!("{}", z), correct); Ok(()) } diff --git a/russell_lab/examples/vector_dot_scale_and_copy.rs b/russell_lab/examples/vector_dot_scale_and_copy.rs index 66f1dfbb..8af96f40 100644 --- a/russell_lab/examples/vector_dot_scale_and_copy.rs +++ b/russell_lab/examples/vector_dot_scale_and_copy.rs @@ -1,5 +1,19 @@ use russell_lab::*; fn main() -> Result<(), StrError> { + // scale + let mut u = Vector::from(&[1.0, 2.0, 3.0]); + vec_scale(&mut u, 0.5); + let correct = "┌ ┐\n\ + │ 0.5 │\n\ + │ 1 │\n\ + │ 1.5 │\n\ + └ ┘"; + assert_eq!(format!("{}", u), correct); + + // copy + let mut v = Vector::from(&[-1.0, -2.0, -3.0]); + vec_copy(&mut v, &u)?; + assert_eq!(format!("{}", v), correct); Ok(()) } diff --git a/russell_lab/examples/vector_norms.rs b/russell_lab/examples/vector_norms.rs index 66f1dfbb..d5dac835 100644 --- a/russell_lab/examples/vector_norms.rs +++ b/russell_lab/examples/vector_norms.rs @@ -1,5 +1,11 @@ use russell_lab::*; fn main() -> Result<(), StrError> { + let u = Vector::from(&[2.0, -2.0, 2.0, -2.0, -3.0]); + assert_eq!(vec_norm(&u, Norm::One), 11.0); + assert_eq!(vec_norm(&u, Norm::Euc), 5.0); + assert_eq!(vec_norm(&u, Norm::Fro), 5.0); // same as Euc + assert_eq!(vec_norm(&u, Norm::Inf), 3.0); + assert_eq!(vec_norm(&u, Norm::Max), 3.0); // same as Inf Ok(()) } From f47a43a5ea5743c989bccffb5e4576b4b3d9f9cc Mon Sep 17 00:00:00 2001 From: Dorival Pedroso Date: Fri, 19 Apr 2024 14:02:26 +1000 Subject: [PATCH 3/3] [wip] Draft examples. Will create another branch to finalize this --- russell_lab/examples/algo_interpolation_lagrange.rs | 6 ++++++ ...cation.rs => algo_lorene_1d_pde_spectral_collocation.rs} | 0 russell_lab/examples/algo_min_bracketing.rs | 6 ++++++ russell_lab/examples/algo_min_solver_brent.rs | 6 ++++++ .../{numerical_jacobian.rs => algo_numerical_jacobian.rs} | 0 russell_lab/examples/algo_quadrature_integrate_1d.rs | 6 ++++++ russell_lab/examples/algo_root_solver_brent.rs | 6 ++++++ russell_lab/examples/base_auxiliary_blas.rs | 6 ++++++ russell_lab/examples/base_linear_fitting_and_stopwatch.rs | 6 ++++++ russell_lab/examples/base_sort_read_table_and_formatters.rs | 6 ++++++ russell_lab/examples/check_1st_and_2nd_derivatives.rs | 6 ++++++ russell_lab/examples/fftw_simple_example.rs | 6 ++++++ russell_lab/examples/math_bessel_functions.rs | 6 ++++++ russell_lab/examples/math_beta_gamma_and_erf_functions.rs | 6 ++++++ russell_lab/examples/math_complex_numbers.rs | 6 ++++++ russell_lab/examples/math_composition_and_modulo.rs | 6 ++++++ russell_lab/examples/math_elliptic_integral.rs | 6 ++++++ russell_lab/examples/math_functions_and_chebyshev.rs | 6 ++++++ russell_lab/examples/matrix_visualization.rs | 6 ++++++ ...ear_system_solution.rs => matvec_solve_linear_system.rs} | 0 20 files changed, 102 insertions(+) create mode 100644 russell_lab/examples/algo_interpolation_lagrange.rs rename russell_lab/examples/{pde_1d_lorene_spectral_collocation.rs => algo_lorene_1d_pde_spectral_collocation.rs} (100%) create mode 100644 russell_lab/examples/algo_min_bracketing.rs create mode 100644 russell_lab/examples/algo_min_solver_brent.rs rename russell_lab/examples/{numerical_jacobian.rs => algo_numerical_jacobian.rs} (100%) create mode 100644 russell_lab/examples/algo_quadrature_integrate_1d.rs create mode 100644 russell_lab/examples/algo_root_solver_brent.rs create mode 100644 russell_lab/examples/base_auxiliary_blas.rs create mode 100644 russell_lab/examples/base_linear_fitting_and_stopwatch.rs create mode 100644 russell_lab/examples/base_sort_read_table_and_formatters.rs create mode 100644 russell_lab/examples/check_1st_and_2nd_derivatives.rs create mode 100644 russell_lab/examples/fftw_simple_example.rs create mode 100644 russell_lab/examples/math_bessel_functions.rs create mode 100644 russell_lab/examples/math_beta_gamma_and_erf_functions.rs create mode 100644 russell_lab/examples/math_complex_numbers.rs create mode 100644 russell_lab/examples/math_composition_and_modulo.rs create mode 100644 russell_lab/examples/math_elliptic_integral.rs create mode 100644 russell_lab/examples/math_functions_and_chebyshev.rs create mode 100644 russell_lab/examples/matrix_visualization.rs rename russell_lab/examples/{linear_system_solution.rs => matvec_solve_linear_system.rs} (100%) diff --git a/russell_lab/examples/algo_interpolation_lagrange.rs b/russell_lab/examples/algo_interpolation_lagrange.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/algo_interpolation_lagrange.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/pde_1d_lorene_spectral_collocation.rs b/russell_lab/examples/algo_lorene_1d_pde_spectral_collocation.rs similarity index 100% rename from russell_lab/examples/pde_1d_lorene_spectral_collocation.rs rename to russell_lab/examples/algo_lorene_1d_pde_spectral_collocation.rs diff --git a/russell_lab/examples/algo_min_bracketing.rs b/russell_lab/examples/algo_min_bracketing.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/algo_min_bracketing.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/algo_min_solver_brent.rs b/russell_lab/examples/algo_min_solver_brent.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/algo_min_solver_brent.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/numerical_jacobian.rs b/russell_lab/examples/algo_numerical_jacobian.rs similarity index 100% rename from russell_lab/examples/numerical_jacobian.rs rename to russell_lab/examples/algo_numerical_jacobian.rs diff --git a/russell_lab/examples/algo_quadrature_integrate_1d.rs b/russell_lab/examples/algo_quadrature_integrate_1d.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/algo_quadrature_integrate_1d.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/algo_root_solver_brent.rs b/russell_lab/examples/algo_root_solver_brent.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/algo_root_solver_brent.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/base_auxiliary_blas.rs b/russell_lab/examples/base_auxiliary_blas.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/base_auxiliary_blas.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/base_linear_fitting_and_stopwatch.rs b/russell_lab/examples/base_linear_fitting_and_stopwatch.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/base_linear_fitting_and_stopwatch.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/base_sort_read_table_and_formatters.rs b/russell_lab/examples/base_sort_read_table_and_formatters.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/base_sort_read_table_and_formatters.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/check_1st_and_2nd_derivatives.rs b/russell_lab/examples/check_1st_and_2nd_derivatives.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/check_1st_and_2nd_derivatives.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/fftw_simple_example.rs b/russell_lab/examples/fftw_simple_example.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/fftw_simple_example.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/math_bessel_functions.rs b/russell_lab/examples/math_bessel_functions.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/math_bessel_functions.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/math_beta_gamma_and_erf_functions.rs b/russell_lab/examples/math_beta_gamma_and_erf_functions.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/math_beta_gamma_and_erf_functions.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/math_complex_numbers.rs b/russell_lab/examples/math_complex_numbers.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/math_complex_numbers.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/math_composition_and_modulo.rs b/russell_lab/examples/math_composition_and_modulo.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/math_composition_and_modulo.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/math_elliptic_integral.rs b/russell_lab/examples/math_elliptic_integral.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/math_elliptic_integral.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/math_functions_and_chebyshev.rs b/russell_lab/examples/math_functions_and_chebyshev.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/math_functions_and_chebyshev.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/matrix_visualization.rs b/russell_lab/examples/matrix_visualization.rs new file mode 100644 index 00000000..c8e42bbd --- /dev/null +++ b/russell_lab/examples/matrix_visualization.rs @@ -0,0 +1,6 @@ +use russell_lab::*; + +fn main() -> Result<(), StrError> { + println!("TODO: EXAMPLE"); + Ok(()) +} diff --git a/russell_lab/examples/linear_system_solution.rs b/russell_lab/examples/matvec_solve_linear_system.rs similarity index 100% rename from russell_lab/examples/linear_system_solution.rs rename to russell_lab/examples/matvec_solve_linear_system.rs