public static IEnumerable <long> MaxCostAssignment <T>(Matrix <T> cost) where T : struct { if (cost == null) { throw new ArgumentNullException(nameof(cost)); } if (cost.Rows != cost.Columns) { throw new ArgumentException($"{cost.Rows} must equal to {cost.Columns}"); } using (var vector = new VectorOfLong()) { var type = cost.MatrixElementType.ToNativeMatrixElementType(); var ret = Native.max_cost_assignment( type, cost.NativePtr, vector.NativePtr); if (ret == Native.ErrorType.MatrixElementTypeNotSupport) { throw new ArgumentException($"{cost.MatrixElementType} is not supported."); } return(vector.ToArray()); } }
public void CreateWithCollection() { const int size = 10; var source = Enumerable.Range(0, size).Select(s => (long)s).ToArray(); var vector = new VectorOfLong(source); Assert.AreEqual(vector.Size, size); var ret = vector.ToArray(); for (var i = 0; i < size; i++) { Assert.AreEqual(ret[i], i); } this.DisposeAndCheckDisposedState(vector); }