@@ -127,8 +127,7 @@ public static void WriteMatrix<T>(TextWriter writer, Matrix<T> matrix) where T :
127127 var format = CreateValueFormatter < T > ( ) ;
128128 var storage = matrix . Storage ;
129129
130- var sparse = storage as SparseCompressedRowMatrixStorage < T > ;
131- if ( sparse != null )
130+ if ( storage is SparseCompressedRowMatrixStorage < T > sparse )
132131 {
133132 writer . WriteLine ( "%%MatrixMarket matrix coordinate {0} general" , complex ? "complex" : "real" ) ;
134133 writer . WriteLine ( "{0} {1} {2}" , sparse . RowCount , sparse . ColumnCount , sparse . ValueCount ) ;
@@ -144,8 +143,7 @@ public static void WriteMatrix<T>(TextWriter writer, Matrix<T> matrix) where T :
144143 return ;
145144 }
146145
147- var diagonal = storage as DiagonalMatrixStorage < T > ;
148- if ( diagonal != null )
146+ if ( storage is DiagonalMatrixStorage < T > diagonal )
149147 {
150148 writer . WriteLine ( "%%MatrixMarket matrix coordinate {0} general" , complex ? "complex" : "real" ) ;
151149 writer . WriteLine ( "{0} {1} {2}" , diagonal . RowCount , diagonal . ColumnCount , diagonal . Data . Length ) ;
@@ -157,8 +155,7 @@ public static void WriteMatrix<T>(TextWriter writer, Matrix<T> matrix) where T :
157155 return ;
158156 }
159157
160- var dense = storage as DenseColumnMajorMatrixStorage < T > ;
161- if ( dense != null )
158+ if ( storage is DenseColumnMajorMatrixStorage < T > dense )
162159 {
163160 writer . WriteLine ( "%%MatrixMarket matrix array {0} general" , complex ? "complex" : "real" ) ;
164161 writer . WriteLine ( "{0} {1}" , dense . RowCount , dense . ColumnCount ) ;
@@ -184,8 +181,7 @@ public static void WriteVector<T>(TextWriter writer, Vector<T> vector) where T :
184181 var format = CreateValueFormatter < T > ( ) ;
185182 var storage = vector . Storage ;
186183
187- var sparse = storage as SparseVectorStorage < T > ;
188- if ( sparse != null )
184+ if ( storage is SparseVectorStorage < T > sparse )
189185 {
190186 writer . WriteLine ( "%%MatrixMarket vector coordinate {0}" , complex ? "complex" : "real" ) ;
191187 writer . WriteLine ( "{0} {1}" , sparse . Length , sparse . ValueCount ) ;
@@ -197,8 +193,7 @@ public static void WriteVector<T>(TextWriter writer, Vector<T> vector) where T :
197193 return ;
198194 }
199195
200- var dense = storage as DenseVectorStorage < T > ;
201- if ( dense != null )
196+ if ( storage is DenseVectorStorage < T > dense )
202197 {
203198 writer . WriteLine ( "%%MatrixMarket vector array {0}" , complex ? "complex" : "real" ) ;
204199 writer . WriteLine ( "{0}" , dense . Length ) ;
0 commit comments