Expand description
Block tensor type for GMRES with block matrices.
This module provides BlockTensor, a collection of tensors organized
in a block structure. It implements TensorLike for the vector space
operations required by GMRES, allowing block matrix linear equations
Ax = b to be solved using the existing GMRES implementation.
§Example
use tensor4all_core::block_tensor::BlockTensor;
use tensor4all_core::krylov::{gmres, GmresOptions};
use tensor4all_core::{DynIndex, TensorDynLen};
let i = DynIndex::new_dyn(2);
let b_block = TensorDynLen::from_dense(vec![i.clone()], vec![1.0, 2.0])?;
let zero_block = TensorDynLen::from_dense(vec![i.clone()], vec![0.0, 0.0])?;
let b = BlockTensor::new(vec![b_block], (1, 1));
let x0 = BlockTensor::new(vec![zero_block], (1, 1));
let apply_a = |x: &BlockTensor<TensorDynLen>| Ok(x.clone());
let result = gmres(apply_a, &b, &x0, &GmresOptions::default())?;
assert!(result.converged);
assert_eq!(result.solution.shape(), (1, 1));Structs§
- Block
Tensor - A collection of tensors organized in a block structure.