BlockVector
The `BlockVector` class in the `sofa::linearalgebra` namespace is part of the Sofa framework's LinearAlgebra module and inherits from `FullVector`. It represents a vector composed of blocks, where each block has a fixed size specified by the template parameter `N`, and the type of elements within each block is given by `T`. The class defines methods to access sub-blocks (`sub`) and address-based sub-blocks (`asub`). These methods allow for efficient manipulation of vectors organized into structured segments. This component is typically used in scenarios where data organization in blocks can lead to more efficient memory management or faster access patterns, such as in specialized numerical algorithms or simulations requiring segmented data handling.
- abstract
- `BlockVector` organizes vector data into fixed-size blocks, providing efficient block-based access methods (`sub`, `asub`). It extends the functionality of standard vectors by enabling structured manipulation and storage.
- sheet
- # BlockVector **Overview** The `BlockVector` class in the `sofa::linearalgebra` namespace is part of the Sofa framework's LinearAlgebra module. It inherits from `FullVector`, extending its functionality to organize vector data into fixed-size blocks, where each block has a size specified by the template parameter `N`. This structure allows for efficient manipulation and storage of vectors organized into structured segments. **Mathematical Model** 1. **Vector Representation**: - The vector can be represented as a collection of blocks, where each block contains a fixed number (`N`) of elements. If the overall size of the `BlockVector` is `m`, and each block has `N` elements, then `m = n * N` for some integer `n`. The vector can be denoted as: \[ \mathbf{v} = [\mathbf{b}_1, \mathbf{b}_2, \ldots, \mathbf{b}_n] \] where each block \( \mathbf{b}_i \) is a vector of length `N`. For example, if `N = 6`, and the overall size `m = 18`, then: \[ \mathbf{v} = [\mathbf{b}_1, \mathbf{b}_2, \mathbf{b}_3] \] where each block \( \mathbf{b}_i \) has 6 elements. 2. **Accessing Sub-blocks**: - The method `sub(Index i)` allows accessing the `i`-th sub-vector (block) within the `BlockVector`. For example, if \( \mathbf{v} \) is a `BlockVector<6>` and we want to access the second block, it would return the sub-vector starting at index 6. - The method `asub(Index bi)` allows accessing the block based on an address within the overall vector. This can be useful for direct memory access or indexing into specific blocks by their offset in the entire vector.
- description
- The `BlockVector` class in the `sofa::linearalgebra` namespace is part of the Sofa framework's LinearAlgebra module and inherits from `FullVector`. It represents a vector composed of blocks, where each block has a fixed size specified by the template parameter `N`, and the type of elements within each block is given by `T`. The class defines methods to access sub-blocks (`sub`) and address-based sub-blocks (`asub`). These methods allow for efficient manipulation of vectors organized into structured segments. This component is typically used in scenarios where data organization in blocks can lead to more efficient memory management or faster access patterns, such as in specialized numerical algorithms or simulations requiring segmented data handling.
- maths
- The `BlockVector` class in the `sofa::linearalgebra` namespace is part of the Sofa framework's LinearAlgebra module and inherits from `FullVector`. It represents a vector composed of blocks, where each block has a fixed size specified by the template parameter `N`, and the type of elements within each block is given by `T`. This structure allows for efficient manipulation and storage of vectors organized into structured segments. Below is a detailed mathematical description: ### Mathematical Description 1. **Vector Representation**: - The vector can be represented as a collection of blocks, where each block contains a fixed number (`N`) of elements. If the overall size of the `BlockVector` is `m`, and each block has `N` elements, then `m = n * N` for some integer `n`. The vector can be denoted as: \[ \mathbf{v} = [\mathbf{b}_1, \mathbf{b}_2, \ldots, \mathbf{b}_n] \] where each block \( \mathbf{b}_i \) is a vector of length `N`. For example, if `N = 6`, and the overall size `m = 18`, then: \[ \mathbf{v} = [\mathbf{b}_1, \mathbf{b}_2, \mathbf{b}_3] \] where each block \( \mathbf{b}_i \) has 6 elements. 2. **Accessing Sub-blocks**: - The method `sub(Index i)` allows accessing the `i`-th sub-vector (block) within the `BlockVector`. For example, if \( \mathbf{v} \) is a `BlockVector<6>` and we want to access the second block, it would return the sub-vector starting at index 6. - The method `asub(Index bi)` allows accessing the block based on an address within the overall vector. This can be useful for direct memory access or indexing into specific blocks by their offset in the entire vector. ### Physical Description 1. **Use Cases**: - In simulation frameworks, vectors often represent physical quantities such as displacements, velocities, or forces. By organizing these values into blocks, one can achieve more efficient memory management and faster access patterns. For instance, if each node in a finite element model has six degrees of freedom (three for position and three for velocity), then a `BlockVector<6>` can efficiently store the state information. 2. **Efficiency**: - Block structures enable optimized operations such as vector addition or scalar multiplication when applied to entire blocks at once, reducing overhead compared to element-wise operations on unstructured vectors. 3. **Memory Management**: - Grouping elements into fixed-size blocks can lead to better memory alignment and cache utilization, which is critical for performance in numerical simulations. ### Summary The `BlockVector` class provides a structured way of organizing vector data into blocks of fixed size, leading to more efficient manipulation and storage. This structure is particularly useful in simulation frameworks where physical quantities often have a natural grouping or when memory alignment can significantly impact performance.
{
"name": "BlockVector",
"main": {
"name": "BlockVector",
"namespace": "sofa::linearalgebra",
"module": "Sofa.framework.LinearAlgebra",
"include": "sofa/linearalgebra/BlockVector.h",
"doc": "",
"inherits": [
"FullVector"
],
"templates": [
"6, SReal"
],
"data_fields": [],
"links": [],
"methods": [
{
"name": "sub",
"return_type": "const Block &",
"params": [
{
"name": "i",
"type": "Index"
},
{
"name": "",
"type": "Index"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "asub",
"return_type": "const Block &",
"params": [
{
"name": "bi",
"type": "Index"
},
{
"name": "",
"type": "Index"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
]
},
"desc": {
"description": "The `BlockVector` class in the `sofa::linearalgebra` namespace is part of the Sofa framework's LinearAlgebra module and inherits from `FullVector`. It represents a vector composed of blocks, where each block has a fixed size specified by the template parameter `N`, and the type of elements within each block is given by `T`. The class defines methods to access sub-blocks (`sub`) and address-based sub-blocks (`asub`). These methods allow for efficient manipulation of vectors organized into structured segments. This component is typically used in scenarios where data organization in blocks can lead to more efficient memory management or faster access patterns, such as in specialized numerical algorithms or simulations requiring segmented data handling."
},
"maths": {
"maths": "The `BlockVector` class in the `sofa::linearalgebra` namespace is part of the Sofa framework's LinearAlgebra module and inherits from `FullVector`. It represents a vector composed of blocks, where each block has a fixed size specified by the template parameter `N`, and the type of elements within each block is given by `T`. This structure allows for efficient manipulation and storage of vectors organized into structured segments. Below is a detailed mathematical description:\n\n### Mathematical Description\n\n1. **Vector Representation**:\n - The vector can be represented as a collection of blocks, where each block contains a fixed number (`N`) of elements.\n \n If the overall size of the `BlockVector` is `m`, and each block has `N` elements, then `m = n * N` for some integer `n`. The vector can be denoted as:\n \\[ \\mathbf{v} = [\\mathbf{b}_1, \\mathbf{b}_2, \\ldots, \\mathbf{b}_n] \\]\n where each block \\( \\mathbf{b}_i \\) is a vector of length `N`.\n\n For example, if `N = 6`, and the overall size `m = 18`, then:\n \\[ \\mathbf{v} = [\\mathbf{b}_1, \\mathbf{b}_2, \\mathbf{b}_3] \\]\n where each block \\( \\mathbf{b}_i \\) has 6 elements.\n\n2. **Accessing Sub-blocks**:\n - The method `sub(Index i)` allows accessing the `i`-th sub-vector (block) within the `BlockVector`. For example, if \\( \\mathbf{v} \\) is a `BlockVector<6>` and we want to access the second block, it would return the sub-vector starting at index 6.\n\n - The method `asub(Index bi)` allows accessing the block based on an address within the overall vector. This can be useful for direct memory access or indexing into specific blocks by their offset in the entire vector.\n\n### Physical Description\n\n1. **Use Cases**:\n - In simulation frameworks, vectors often represent physical quantities such as displacements, velocities, or forces. By organizing these values into blocks, one can achieve more efficient memory management and faster access patterns. For instance, if each node in a finite element model has six degrees of freedom (three for position and three for velocity), then a `BlockVector<6>` can efficiently store the state information.\n\n2. **Efficiency**:\n - Block structures enable optimized operations such as vector addition or scalar multiplication when applied to entire blocks at once, reducing overhead compared to element-wise operations on unstructured vectors.\n\n3. **Memory Management**:\n - Grouping elements into fixed-size blocks can lead to better memory alignment and cache utilization, which is critical for performance in numerical simulations.\n\n### Summary\nThe `BlockVector` class provides a structured way of organizing vector data into blocks of fixed size, leading to more efficient manipulation and storage. This structure is particularly useful in simulation frameworks where physical quantities often have a natural grouping or when memory alignment can significantly impact performance."
},
"summary": {
"abstract": "`BlockVector` organizes vector data into fixed-size blocks, providing efficient block-based access methods (`sub`, `asub`). It extends the functionality of standard vectors by enabling structured manipulation and storage.",
"sheet": "# BlockVector\n\n**Overview**\n\nThe `BlockVector` class in the `sofa::linearalgebra` namespace is part of the Sofa framework's LinearAlgebra module. It inherits from `FullVector`, extending its functionality to organize vector data into fixed-size blocks, where each block has a size specified by the template parameter `N`. This structure allows for efficient manipulation and storage of vectors organized into structured segments.\n\n**Mathematical Model**\n\n1. **Vector Representation**:\n - The vector can be represented as a collection of blocks, where each block contains a fixed number (`N`) of elements.\n \n If the overall size of the `BlockVector` is `m`, and each block has `N` elements, then `m = n * N` for some integer `n`. The vector can be denoted as:\n \\[ \\mathbf{v} = [\\mathbf{b}_1, \\mathbf{b}_2, \\ldots, \\mathbf{b}_n] \\]\n where each block \\( \\mathbf{b}_i \\) is a vector of length `N`.\n\n For example, if `N = 6`, and the overall size `m = 18`, then:\n \\[ \\mathbf{v} = [\\mathbf{b}_1, \\mathbf{b}_2, \\mathbf{b}_3] \\]\n where each block \\( \\mathbf{b}_i \\) has 6 elements.\n\n2. **Accessing Sub-blocks**:\n - The method `sub(Index i)` allows accessing the `i`-th sub-vector (block) within the `BlockVector`. For example, if \\( \\mathbf{v} \\) is a `BlockVector<6>` and we want to access the second block, it would return the sub-vector starting at index 6.\n\n - The method `asub(Index bi)` allows accessing the block based on an address within the overall vector. This can be useful for direct memory access or indexing into specific blocks by their offset in the entire vector."
}
}