Function quest_bind::init_complex_matrix_n
source · pub fn init_complex_matrix_n(
m: &mut ComplexMatrixN,
real: &[&[Qreal]],
imag: &[&[Qreal]]
) -> Result<(), QuestError>
Expand description
Initialises a ComplexMatrixN
instance to have the passed
real
and imag
values.
This function reimplements the functionality of QuEST
’s
initComplexMatrix()
, instead of calling that function directly. This way,
we avoid transmuting the slice of slices passed as argument into a C array
and simply copy the matrix elements onto the QuEST
matrix type.
Examples
let mtr = &mut ComplexMatrixN::try_new(1).unwrap();
init_complex_matrix_n(
mtr,
&[&[1., 2.], &[3., 4.]],
&[&[5., 6.], &[7., 8.]],
)
.unwrap();
See QuEST API for more information.
Errors
Returns ArrayLengthError
, if
either real
or imag
is not a square array of dimension equal to the
number of qubits in m
.