Skip to content

Commit 5ddb3ef

Browse files
authored
Merge branch 'master' into residualstopcriterion-crash-zero-vector
2 parents 8e8c0b7 + 037b98c commit 5ddb3ef

File tree

29 files changed

+1477
-80
lines changed

29 files changed

+1477
-80
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
]
1010
},
1111
"fsharp.formatting.commandtool": {
12-
"version": "11.4.1",
12+
"version": "11.5.1",
1313
"commands": [
1414
"fsdocs"
1515
]

RELEASENOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Random: xoshiro256StarStar fix out of range exception *~Charlie Turndorf*
1212
* Precision: Perf: pre-compute negative powers *~Febin*
1313
* Optimizations: Remove static properties in LevenbergMarquardtMinimizer *~Jong Hyun Kim*
14-
* Root Finding: Newton-Raphson better handling of zero-evaluations
14+
* Root Finding: Newton-Raphson better handling of zero-evaluations *~jkalias*
1515
* Fit.Curve and FindMinimum extended to accept two more parameters
1616
* Fixed an index out of bounds issue when calculating BFGS minimizer with one variable *~Shiney*
1717
* Fixed Sparse COO NormalizeDuplicates *~Mohamed Moussa*

data/Matlab/cell-array-nested.mat

377 Bytes
Binary file not shown.

data/Matlab/struct-nested.mat

287 Bytes
Binary file not shown.

src/Data.Matlab/Data.Matlab.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Random: NextBigIngegerSequence ~Silver-Fang
2525
Random: xoshiro256StarStar fix out of range exception ~Charlie Turndorf
2626
Precision: Perf: pre-compute negative powers ~Febin
2727
Optimizations: Remove static properties in LevenbergMarquardtMinimizer ~Jong Hyun Kim
28-
Root Finding: Newton-Raphson better handling of zero-evaluations
28+
Root Finding: Newton-Raphson better handling of zero-evaluations ~jkalias
2929
Fit.Curve and FindMinimum extended to accept two more parameters
3030
Fixed an index out of bounds issue when calculating BFGS minimizer with one variable ~Shiney
3131
Fixed Sparse COO NormalizeDuplicates ~Mohamed Moussa
@@ -56,13 +56,14 @@ Control.Describe now includes CPU architecture and family identifier if know</Pa
5656
<ProjectReference Include="..\Numerics\Numerics.csproj" />
5757
</ItemGroup>
5858
<ItemGroup>
59-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0">
59+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.1">
6060
<PrivateAssets>all</PrivateAssets>
6161
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6262
</PackageReference>
6363
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
6464
<PrivateAssets>all</PrivateAssets>
6565
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6666
</PackageReference>
67+
<PackageReference Include="OneOf" Version="3.0.223" />
6768
</ItemGroup>
6869
</Project>

src/Data.Matlab/MatlabReader.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ public static Matrix<T> Unpack<T>(MatlabMatrix matrixData)
7070
return Parser.ParseMatrix<T>(matrixData.Data);
7171
}
7272

73+
/// <summary>
74+
/// Unpacks a MATLAB object that cannot be mapped to a MathNet.Numerics matrix. This could be any nesting of cell matrices and structures.
75+
/// The nesting must bottom out on either a MathNet.Numerics matrix (if the lowest level values here are matrices of a numeric type) or a character mattrix (if the lowest level value is a matrix of a char type)
76+
/// Since structures and cell matrices can have different data types in different fields and can even be nested the type of the field value cannot be more specific than a nested object
77+
/// </summary>
78+
/// <returns></returns>
79+
public static NestedObject NonNumeric(MatlabMatrix structData)
80+
{
81+
return Parser.ParseNonNumeric(structData.Data);
82+
}
83+
84+
7385
/// <summary>
7486
/// Read the first or a specific matrix from a MATLAB file stream.
7587
/// </summary>

src/Data.Matlab/MatlabStructure.cs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// <copyright file="MatlabStructure.cs" company="Math.NET">
2+
// Math.NET Numerics, part of the Math.NET Project
3+
// https://numerics.mathdotnet.com
4+
// https://github.com/mathnet/mathnet-numerics
5+
//
6+
// Copyright (c) 2009-$CURRENT_YEAR$ Math.NET
7+
//
8+
// Permission is hereby granted, free of charge, to any person
9+
// obtaining a copy of this software and associated documentation
10+
// files (the "Software"), to deal in the Software without
11+
// restriction, including without limitation the rights to use,
12+
// copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the
14+
// Software is furnished to do so, subject to the following
15+
// conditions:
16+
//
17+
// The above copyright notice and this permission notice shall be
18+
// included in all copies or substantial portions of the Software.
19+
//
20+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22+
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27+
// OTHER DEALINGS IN THE SOFTWARE.
28+
// </copyright>
29+
30+
using MathNet.Numerics.LinearAlgebra;
31+
using OneOf;
32+
using System.Collections.Generic;
33+
using System.Text;
34+
35+
namespace MathNet.Numerics.Data.Matlab
36+
{
37+
public class MatlabStructure : Dictionary<string, NestedObject>
38+
{
39+
}
40+
41+
public class MatlabCellMatrix
42+
{
43+
public NestedObject[,] Data { get; private set; }
44+
45+
public MatlabCellMatrix(int rows, int cols)
46+
{
47+
Data = new NestedObject[rows, cols];
48+
}
49+
}
50+
51+
public class MatlabCharMatrix
52+
{
53+
/// <summary>
54+
/// Typically not that relevant, for UTF32 encoding however each single char is actually 2 chars (hence the string type)
55+
/// </summary>
56+
public Encoding Encoding { get; private set; }
57+
public string[,] Data { get; private set; }
58+
59+
public MatlabCharMatrix(int rows, int cols, Encoding encoding)
60+
{
61+
Encoding = encoding;
62+
63+
Data = new string[rows, cols];
64+
}
65+
66+
/// <summary>
67+
/// Returns each row as a single string
68+
/// </summary>
69+
/// <returns></returns>
70+
public string[] ConcatRows()
71+
{
72+
string[] result = new string[Data.GetLength(0)];
73+
for (int col = 0; col < Data.GetLength(1); col++)
74+
{
75+
for (int row = 0; row < Data.GetLength(0); row++)
76+
77+
{
78+
result[row] += Data[row, col];
79+
}
80+
}
81+
82+
return result;
83+
}
84+
}
85+
86+
public class NestedObject : OneOfBase<MatlabStructure, MatlabCellMatrix, MatlabCharMatrix, MatlabMatrix>
87+
{
88+
public NestedObject(OneOf<MatlabStructure, MatlabCellMatrix, MatlabCharMatrix, MatlabMatrix> input) : base(input)
89+
{
90+
}
91+
}
92+
}

0 commit comments

Comments
 (0)