Investigate By-Ref Vector and Matrix Operators in C# 8.0
See original GitHub issueSummary
As mentioned in issue #598, the new in
parameter keyword is allowed on operators and using literal values, so operator implementations can supersede the previous static by-ref operator alternatives.
Analysis
- Wait until the core has adopted C# 7.2.
- Make sure using the
in
keyword implicitly with non-referencable values (like literals or property return values) has no negative impact on performance. Read the docs, and if that’s not 100% clear, check out generated IL and x86 code in a sample project. - Remove all static by-
ref
methods fromVector2/3/4
,Quaternion
andMatrix3/4
if they have an operator equivalent. - Use the
in
keyword on parameters provided to the operators in question.
Issue Analytics
- State:
- Created 6 years ago
- Comments:22 (22 by maintainers)
Top Results From Across the Web
Easy matrix - Page 2
(I use array of matrix 1 to whatever, but 0 to whatever would be OK) ... operator * ( byref a as Matrix...
Read more >7.5 Matrices and Matrix Operations - College Algebra 2e
We will investigate this idea further in the next section, but first we will look at basic matrix operations. Matrices. A matrix is...
Read more >Performance: Matlab vs C++ Matrix vector multiplication
I have a slightly larger code, from which I am investigating a segment of matrix-vector multiplication. The larger code performs such ...
Read more >2.2: Matrix multiplication and linear combinations
This means that we may define scalar multiplication and matrix addition operations using the corresponding vector operations.
Read more >Matrix Operations - Yung-Yu's Notes
Vector : 1D Array#. We may use a 1D array (a contiguous memory buffer of sequentially ordered elements) to store a vector. Small...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As a further enhancement one can add readonly to properties and methods etc now in C#8.0 to denote they do not change state: https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8#readonly-members
(in C# 7.3 this was only possible on struct level)
This will enable the compiler to skip more defensive copies.
There are cases where defensive copies might occur when using the
in
keyword. This can reduce the performance. Making the structreadonly
will prevent this.https://blogs.msdn.microsoft.com/seteplia/2018/03/07/the-in-modifier-and-the-readonly-structs-in-c/
However since the
X
,Y
etc fields are part of the public API its basically a breaking change.