Skip to content

Add variadic version of scalar_seq_view #2951

@andrjohns

Description

@andrjohns

Description

In the finite-diff framework PR (and some other functions that I'm planning), we need to be able to sequentially iterate through each element of all arguments passed to a function.

The current approach is to use the serializer/deserializer framework which copies all values to a single Eigen::VectorXd and then re-constructs the arguments to the appropriate shape/size by passing in the original arguments. This obviously introduces pretty significant overhead in both copy and memory costs.

A better alternative would be to extend scalar_seq_view to take a variadic number of arguments, and then in the []/() index operator use a hash table to map the input index to the appropriate value in the appropriate argument

Example

In Math pseudo-code, something like:

Eigen::VectorXd a_vec(2);
Eigen::MatrixXd b_mat(2,2);

scalar_seq_view<Eigen::VectorXd, Eigen::MatrixXd> args_view(a_vec, b_mat);

args_view[0]; // Returns a_vec[0]
args_view[1]; // Returns a_vec[1]
args_view[2]; // Returns b_mat(0, 0)
args_view[3]; // Returns b_mat(1, 0)
args_view[4]; // Returns b_mat(0, 1)
args_view[5]; // Returns b_mat(1, 1)

Current Version:

v4.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions