Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Scalar.As added BigInteger and Complex #646

Merged
merged 8 commits into from
Oct 23, 2021

Conversation

WhiteBlackGoose
Copy link
Contributor

Now T4-backed

Closes #639

@WhiteBlackGoose WhiteBlackGoose marked this pull request as ready for review October 18, 2021 07:45
/// <summary>
/// A collection of operations for working with scalar numeric values.
/// Includes methods like the ones found in <see cref="Math"/> and more.
/// Supports <see cref="Half"/>, <see cref="float"/>, <see cref="double"/>, <see cref="decimal"/>, <see cref="sbyte"/>, <see cref="byte"/>, <see cref="ushort"/>, <see cref="short"/>, <see cref="uint"/>, <see cref="int"/>, <see cref="ulong"/> and <see cref="long"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generate this comment maybe?

[MethodImpl(MaxOpt)]
public static TTo As<TFrom, TTo>(TFrom val) where TFrom : notnull where TTo : notnull
{
if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(Half))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why what?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this exist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does exist?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this whole self written method exist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh. It's not method, but now I realized that I can make it a method, and clean the template a bit. Thanks


#>
<# if (types[i] == "Complex") { #>
return (TTo) (object) (<#= types[j] #>)<#= intermediateType #> ((<#= types[i] #>) (object) val).Real;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add a remark to the docs.

Copy link
Member

@HurricanKai HurricanKai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to handle the case where TTo is Complex? Or does the explicit conversion already just set the Real?

Comment on lines 76 to 77
/// While in most cases the types can be just explicitly casted,
/// sometimes there is an intermediate cast to float or double.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These shouldn't be part of the summary, but a remark.
Also add another remark that for Complex we only use the Real part

@WhiteBlackGoose
Copy link
Contributor Author

@HurricanKai fixed. Question. I currently include BigInteger and Complex in "Supported" section in the docs - should I exclude them, since they're not fully supported? Or keep as is?

Copy link
Member

@HurricanKai HurricanKai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last nitpick.
I think keeping it like this is fine otherwise.

WhiteBlackGoose and others added 2 commits October 23, 2021 21:19
Co-authored-by: Kai Jellinghaus <contact@kaij.tech>
@HurricanKai HurricanKai enabled auto-merge (squash) October 23, 2021 18:49
@HurricanKai HurricanKai merged commit ef9724b into dotnet:main Oct 23, 2021
Perksey pushed a commit that referenced this pull request Nov 20, 2023
* Scalar.As added BigInteger and Complex

Now T4-backed

* but i included those files????

* Working on intermediate casts

* Fixing intermediate casts

* PR review fixes

* PR comments

* Update src/Maths/Silk.NET.Maths/Scalar.As.tt

Co-authored-by: Kai Jellinghaus <contact@kaij.tech>

* Ran the template

Co-authored-by: Kai Jellinghaus <contact@kaij.tech>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scalar.As to be generated by T4?
2 participants