Skip to content

Have CustomOperation::to_matrix return Result<T, E> instead of Option<T>. #16862

Description

@davidfcohen

What should we add?

The trait member CustomOperation::matrix should be fallible. Also, to_matrix is a more appropriate name for this function.

Potential Errors

  • matrix exceeds the system size limit
  • number of qubits is 0
  • to_matrix is unimplemented

Example

pub trait CustomOperation {
    // Use boxed error because a generic error causes problems downstream.
    fn to_matrix(&self) -> Result<Array2<Complex64>, Box<dyn error::Error>>;
}

Metadata

Metadata

Assignees

Projects

Status
Ready

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions