Missing method exception on DenseMatrix.OfArray(Single[,])

Jul 2, 2013 at 10:38 PM
Edited Jul 2, 2013 at 10:40 PM
Hi,

I am using Math.NET Numerics in a Xamarin.iOS project using Xamarin Studio on a Mac. I am new to C# so this might be something obvious to veterans here. I am porting a Java project that used JAMA.

Here's the relevant part of the code:
Single[,] designData = new Single[n, 6];
for (int i = 0; i < n; i++)
{
    designData [i, 0] = x [i] * x [i];
    designData [i, 1] = x [i] * y [i];
    designData [i, 2] = y [i] * y [i];
    designData [i, 3] = x [i];
    designData [i, 4] = y [i];
    designData [i, 5] = 1.0f;
}

Matrix<float> design = DenseMatrix.OfArray(designData); // runtime exception
This compiles as expected but it throws System.MissingMethodException at the indicated line, saying: Method not found: 'System.Type.op_Equality'.

Any advice on how to proceed? Maybe I'm just using it wrong?

Here is the stacktrace:
MathNet.Numerics.LinearAlgebra.Storage.MatrixStorage<float>..cctor () in 
MathNet.Numerics.LinearAlgebra.Storage.DenseColumnMajorMatrixStorage<float>..ctor (rows=17, columns=6) in 
MathNet.Numerics.LinearAlgebra.Storage.DenseColumnMajorMatrixStorage<float>.OfArray (array={float[17,6]}) in 
MathNet.Numerics.LinearAlgebra.Single.DenseMatrix.OfArray (array={float[17,6]}) in 
Simi.Core.iOS.Algo.RotatedEllipse.FitEllipse (points={OpenTK.Vector2[17]}) in /Users/johnsogg/Projects/SIMI/Code/SIMI/Simi.Core.iOS/Algo/RotatedEllipse.cs:78
Simi.Core.iOS.Algo.Segmenter.DetectArc (stroke={Simi.Core.iOS.Geometry.InkStroke}, i=0) in /Users/johnsogg/Projects/SIMI/Code/SIMI/Simi.Core.iOS/Algo/Segmenter.cs:122
Simi.Core.iOS.Algo.Segmenter.IdentifySegments (stroke={Simi.Core.iOS.Geometry.InkStroke}) in /Users/johnsogg/Projects/SIMI/Code/SIMI/Simi.Core.iOS/Algo/Segmenter.cs:60
Simi.Core.iOS.Algo.InkParser.parse () in /Users/johnsogg/Projects/SIMI/Code/SIMI/Simi.Core.iOS/Algo/InkParser.cs:27
Simi.Core.iOS.Models.GeometryModel.HandlePenUp (stroke={Simi.Core.iOS.Geometry.InkStroke}) in /Users/johnsogg/Projects/SIMI/Code/SIMI/Simi.Core.iOS/Models/GeometryModel.cs:61
Simi.Core.iOS.Models.GeometryModel.HandleInkEvent (ev={Simi.Core.iOS.Events.Input.RawInkEvent}) in /Users/johnsogg/Projects/SIMI/Code/SIMI/Simi.Core.iOS/Models/GeometryModel.cs:53
Simi.Core.iOS.Utilities.EventStream.EventStream.<SubscribeOn>c__AnonStorey2<Simi.Core.iOS.Events.Input.SubscribeOn.AnonymousMethod__3 (o={Simi.Core.iOS.Events.Input.RawInkEvent}) in /Users/johnsogg/Projects/SIMI/Code/SIMI/Simi.Core.iOS/Utilities/EventStream/EventStream.cs:52
Simi.Core.iOS.Utilities.EventStream.InvocationTarget.Invoke.AnonymousMethod__4 () in /Users/johnsogg/Projects/SIMI/Code/SIMI/Simi.Core.iOS/Utilities/EventStream/InvocationTarget.cs:19
Simi.Core.iOS.Utilities.ActionPumpThread.AnonymousMethod__0 () in /Users/johnsogg/Projects/SIMI/Code/SIMI/Simi.Core.iOS/Utilities/ActionPumpThread.cs:24
System.Threading.Thread.StartInternal () in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading/Thread.cs:697
Coordinator
Jul 2, 2013 at 11:43 PM
Hi,

Apparently this can happen when using a compiled library, built against the full .Net4 profile in .Net or Mono, within an application targeting MonoTouch/Xamarin.iOS. It seems Xamarin.iOS still does not support the full .Net4 profile completely yet.

Math.NET Numerics is released in two versions: the primary one for the full .Net4 profile and secondary one as a portable class library for cases where .Net4 is not fully supported. Which one are you referencing right now? In case it's the .Net4 build, could you try again using the portable build instead?

If this doesn't work, we may need to compile directly against the Xamarin.iOS base class library using the Xamarin.iOS compiler instead.

Thanks,
Christoph
Jul 3, 2013 at 6:06 PM
Edited Jul 3, 2013 at 6:26 PM
Thanks for your reply.

Earlier I was using the one for net4. When I swap out the dll to reference the portable version, I get compiler errors.
/Users/johnsogg/Projects/SIMI/Code/SIMI/Simi.Core.iOS/Algo/RotatedEllipse.cs(32,32): Error CS0433: The imported type `System.Numerics.Complex' is defined multiple times (CS0433) (Simi.Core.iOS)

/Users/johnsogg/Projects/SIMI/Code/SIMI/Simi.Core.iOS/Algo/RotatedEllipse.cs(41,41): Error CS0029: Cannot implicitly convert type `MathNet.Numerics.LinearAlgebra.Generic.Vector<System.Numerics.Complex>' to `MathNet.Numerics.LinearAlgebra.Generic.Vector<System.Numerics.Complex>' (CS0029) (Simi.Core.iOS)
It seems this conflicts with the version in Xamarin.iOS. Using the MathNet portable DLL, I can remove Xamarin.iOS's version of System.Numerics from the project's references and it will compile and run. Now I have other problems but they are likely garden variety bugs.