If I is an ideal, then toDual(d,I) = inverseSystem(d, I). See the documentation of InverseSystems for the basic theory and of inverseSystem for the function.
If I is a matrix, then the code first replaces it with the ideal generated by the entries.
The Base ring of the input must be a standard graded polynomial ring over a field.
The object toDual is a method function with options.