@@ -76,8 +76,7 @@ public Markowitz()
76
76
/// <exception cref="ArgumentNullException">pivot</exception>
77
77
public override bool IsValidPivot ( MatrixElement < T > pivot )
78
78
{
79
- if ( pivot == null )
80
- throw new ArgumentNullException ( nameof ( pivot ) ) ;
79
+ pivot . ThrowIfNull ( nameof ( pivot ) ) ;
81
80
82
81
// Get the magnitude of the current pivot
83
82
var magnitude = Magnitude ( pivot . Value ) ;
@@ -104,8 +103,7 @@ public override bool IsValidPivot(MatrixElement<T> pivot)
104
103
/// <exception cref="ArgumentNullException">matrix</exception>
105
104
public void Initialize ( Matrix < T > matrix )
106
105
{
107
- if ( matrix == null )
108
- throw new ArgumentNullException ( nameof ( matrix ) ) ;
106
+ matrix . ThrowIfNull ( nameof ( matrix ) ) ;
109
107
110
108
// Allocate arrays
111
109
_markowitzRow = new int [ matrix . Size + 1 ] ;
@@ -194,8 +192,8 @@ private void Products(SparseMatrix<T> matrix, int step)
194
192
/// <exception cref="ArgumentNullException">matrix</exception>
195
193
public override void Setup ( SparseMatrix < T > matrix , SparseVector < T > rhs , int eliminationStep , Func < T , double > magnitude )
196
194
{
197
- if ( matrix == null )
198
- throw new ArgumentNullException ( nameof ( matrix ) ) ;
195
+ matrix . ThrowIfNull ( nameof ( matrix ) ) ;
196
+ rhs . ThrowIfNull ( nameof ( rhs ) ) ;
199
197
200
198
Magnitude = magnitude ;
201
199
@@ -220,11 +218,13 @@ public override void Setup(SparseMatrix<T> matrix, SparseVector<T> rhs, int elim
220
218
/// </remarks>
221
219
public override void MovePivot ( SparseMatrix < T > matrix , SparseVector < T > rhs , MatrixElement < T > pivot , int eliminationStep )
222
220
{
221
+ matrix . ThrowIfNull ( nameof ( matrix ) ) ;
222
+ rhs . ThrowIfNull ( nameof ( rhs ) ) ;
223
+ pivot . ThrowIfNull ( nameof ( pivot ) ) ;
224
+
223
225
// If we haven't setup, just skip
224
226
if ( _markowitzProduct == null )
225
227
return ;
226
- if ( pivot == null )
227
- throw new ArgumentNullException ( nameof ( pivot ) ) ;
228
228
int oldProduct ;
229
229
230
230
var row = pivot . Row ;
@@ -304,11 +304,12 @@ public override void MovePivot(SparseMatrix<T> matrix, SparseVector<T> rhs, Matr
304
304
/// <exception cref="ArgumentNullException">pivot</exception>
305
305
public override void Update ( SparseMatrix < T > matrix , MatrixElement < T > pivot , int eliminationStep )
306
306
{
307
+ matrix . ThrowIfNull ( nameof ( matrix ) ) ;
308
+ pivot . ThrowIfNull ( nameof ( pivot ) ) ;
309
+
307
310
// If we haven't setup, just skip
308
311
if ( _markowitzProduct == null )
309
312
return ;
310
- if ( pivot == null )
311
- throw new ArgumentNullException ( nameof ( pivot ) ) ;
312
313
313
314
// Go through all elements below the pivot. If they exist, then we can subtract 1 from the Markowitz row vector!
314
315
for ( var column = pivot . Below ; column != null ; column = column . Below )
@@ -347,6 +348,9 @@ public override void Update(SparseMatrix<T> matrix, MatrixElement<T> pivot, int
347
348
/// <param name="fillin">The fill-in.</param>
348
349
public override void CreateFillin ( SparseMatrix < T > matrix , MatrixElement < T > fillin )
349
350
{
351
+ matrix . ThrowIfNull ( nameof ( matrix ) ) ;
352
+ fillin . ThrowIfNull ( nameof ( fillin ) ) ;
353
+
350
354
// Update the markowitz row count
351
355
int index = fillin . Row ;
352
356
_markowitzRow [ index ] ++ ;
@@ -377,6 +381,8 @@ public override void CreateFillin(SparseMatrix<T> matrix, MatrixElement<T> filli
377
381
/// </remarks>
378
382
public override MatrixElement < T > FindPivot ( SparseMatrix < T > matrix , int eliminationStep )
379
383
{
384
+ matrix . ThrowIfNull ( nameof ( matrix ) ) ;
385
+
380
386
foreach ( var strategy in Strategies )
381
387
{
382
388
var chosen = strategy . FindPivot ( this , matrix , eliminationStep ) ;
0 commit comments