# ParametricNDSolveValue has a problem with complex numbers

Bug introduced in version 10 and fixed in 10.3

Edited: I have simplified the example compared to before and narrowed the problem down a bit.

I would like to use ParametricNDSolveValue as function for data fitting. However, I am having trouble with one parameter. That is, ParametricNDSolveValue evaluates just fine when I fix the parameter upfront, but not when I only assign a value to the parameter in the evaluated function.

## Preparations

R[t_] = Through[#[t]] & /@ Table[Subscript[r, i, j], {i, 2}, {j, 2}];


## Problem

I now try to compute the ParametricNDSolveValue with n being a parameter.

ParametricNDSolveValue[{R'[t]==I R[t], R==DiagonalMatrix[{0, n}]}, Subscript[r,2,2], {t,0,10}, {n}]


0.0 + 0.0 I

So that has not worked. But when I fix n in the DE the result is different.

ParametricNDSolveValue[{R'[t]==I R[t], R==DiagonalMatrix[{0, 1}]}, Subscript[r,2,2], {t,0,10}, {n}]


0.540302 + 0.841471 I

Alternatively, when I remove the I in the DE, I get a nontrivial result even with n in the DE.

ParametricNDSolveValue[{R'[t]==  R[t], R==DiagonalMatrix[{0, n}]}, Subscript[r,2,2], {t,0,10}, {n}]


2.71828

## Question

Does anybody understand what is going on? Does ParametricNDSolveValue have a problem with complex numbers and matrices (it does not if the DE are only scalars)?

Thanks a lot for any input!

Seems like this was a bug. It's fixed in Version 10.3.

It is probably a bug introduced in v10. As of v9, these are the results:

R[t_] = Through[#[t]] & /@ Table[Subscript[r, i, j], {i, 2}, {j, 2}];
ParametricNDSolveValue[{R'[t] == I R[t], R == DiagonalMatrix[{0, n}]},
Subscript[r, 2, 2], {t, 0, 10}, {n}]
ParametricNDSolveValue[{R'[t] == I R[t], R == DiagonalMatrix[{0, 1}]},
Subscript[r, 2, 2], {t, 0, 10}, {n}]

(* 0.540302 + 0.841471 I *)
(* 0.540302 + 0.841471 I *)