Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added possibility to create diagonal matrices of different type
- Loading branch information
Showing
17 changed files
with
141 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test/matrix/constructors/identity_constructor/matrix_identity_constructor_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:ml_linalg/dtype.dart'; | ||
|
||
import 'matrix_identity_constructor_test_group_factory.dart'; | ||
|
||
void main() { | ||
matrixIdentityConstructorTestGroupFactory(DType.float32); | ||
} |
26 changes: 26 additions & 0 deletions
26
...rix/constructors/identity_constructor/matrix_identity_constructor_test_group_factory.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:ml_linalg/dtype.dart'; | ||
import 'package:ml_linalg/matrix.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../../dtype_to_class_name_mapping.dart'; | ||
|
||
void matrixIdentityConstructorTestGroupFactory(DType dtype) => | ||
group(dtypeToMatrixClassName[dtype], () { | ||
group('identity constructor', () { | ||
test('should create a matrix with main diagonal elements equal to 1, ' | ||
'and the rest elements equal to 0', () { | ||
|
||
final matrix = Matrix.identity(7, dtype: dtype); | ||
|
||
expect(matrix, equals([ | ||
[1, 0, 0, 0, 0, 0, 0], | ||
[0, 1, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0], | ||
[0, 0, 0, 1, 0, 0, 0], | ||
[0, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0], | ||
[0, 0, 0, 0, 0, 0, 1], | ||
])); | ||
}); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
test/matrix/constructors/scalar_constructor/matrix_scalar_constructor_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:ml_linalg/dtype.dart'; | ||
|
||
import 'matrix_scalar_constructor_test_group_factory.dart'; | ||
|
||
void main() { | ||
matrixScalarConstructorTestGroupFactory(DType.float32); | ||
} |
26 changes: 26 additions & 0 deletions
26
.../matrix/constructors/scalar_constructor/matrix_scalar_constructor_test_group_factory.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:ml_linalg/dtype.dart'; | ||
import 'package:ml_linalg/matrix.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../../dtype_to_class_name_mapping.dart'; | ||
|
||
void matrixScalarConstructorTestGroupFactory(DType dtype) => | ||
group(dtypeToMatrixClassName[dtype], () { | ||
group('scalar constructor', () { | ||
test('should create a matrix with all zero elements except for main ' | ||
'diagonal ones - they should be equal to the given scalar value', () { | ||
|
||
final matrix = Matrix.scalar(-3.0, 7, dtype: dtype); | ||
|
||
expect(matrix, equals([ | ||
[-3, 0, 0, 0, 0, 0, 0], | ||
[ 0, -3, 0, 0, 0, 0, 0], | ||
[ 0, 0, -3, 0, 0, 0, 0], | ||
[ 0, 0, 0, -3, 0, 0, 0], | ||
[ 0, 0, 0, 0, -3, 0, 0], | ||
[ 0, 0, 0, 0, 0, -3, 0], | ||
[ 0, 0, 0, 0, 0, 0, -3], | ||
])); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters