Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update SilkX Proposals #1792

Merged
merged 12 commits into from
Nov 16, 2023
Merged

Update SilkX Proposals #1792

merged 12 commits into from
Nov 16, 2023

Conversation

curin
Copy link
Contributor

@curin curin commented Nov 12, 2023

Summary of the PR

This PR updates the proposals to reflect work being done on SilkX

Related issues, Discord discussions, or proposals

Proposal - Generation Of Library Sources and PInvoke Mechanism
Proposal - Generic Math

- Updated Pointer Proposal to match current implementation
- Add Generic Math Proposal based on Current work
@curin curin requested a review from a team as a code owner November 12, 2023 17:54
@curin curin requested a review from Perksey November 12, 2023 17:54
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
@Perksey
Copy link
Member

Perksey commented Nov 13, 2023

Paging @HurricanKai now we have a formal maths proposal.

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.

Unfortunately I'm not available to review for the next few days. At a glance this looks good and seems to follow the discord discussions.
I'll review this as soon as I can. Also thank you for putting in all the effort!

Copy link
Member

@Perksey Perksey left a comment

Choose a reason for hiding this comment

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

Agree with all the comments above. Where I have written a comment that is applicable to all API definitions, assume that it is indeed applicable (cba to repeat myself).

documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
public Vector2I(TScalar value);
public Vector2I(ReadOnlySpan<TScalar> span);

public Span<TScalar> AsSpan();
Copy link
Member

Choose a reason for hiding this comment

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

This needs [UnscopedRef] (maybe [return: UnscopedRef], I forget) to ensure that the created span is correctly tracked.

/// <returns>The quaternion that contains the summed values of <paramref name="value1" /> and <paramref name="value2" />.</returns>
/// <remarks>The <see cref="op_Addition" /> method defines the operation of the addition operator for <see cref="Quaternion" /> objects.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Quaternion<T> operator +(Quaternion<T> value1, Quaternion<T> value2);
Copy link
Member

Choose a reason for hiding this comment

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

nit: Prefer left and right over value1 and value2 for these, since they are clearly the left and right sides of the + operator.

where TVector : IVector<TVector, TScalar>
where TScalar : INumberBase<TScalar>
{
public TVector ScalarsEqual(TVector other);
Copy link
Member

Choose a reason for hiding this comment

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

Is this returning AllBitsSet for match and Zero for no match?

If so, do the other types need to expose this concept explicitly? Does there then need to be some IndexOfFirstMatch, IndexOfLastMatch, etc?

Should this just be called Equals (like Vector<T> and Vector128<T>) or maybe CompareEqual?

Copy link
Member

Choose a reason for hiding this comment

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

What also, about IVectorComparable for the other comparison operators?

/// <param name="left">The value which multiplies <paramref name="right" />.</param>
/// <returns>The product of <paramref name="right" /> multiplied-by <paramref name="left" />.</returns>
/// <exception cref="OverflowException">The product of <paramref name="right" /> multiplied-by <paramref name="left" /> is not representable by <typeparamref name="TVector" />.</exception>
static virtual TVector operator checked *(TScalar left, TVector right) => right * left;
Copy link
Member

Choose a reason for hiding this comment

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

nit: this should be checked(right * left), the other checked operators need to likewise reuse checked so that overflow checking can happen as expected.

#endregion
}

public interface IModulusVector<TVector, TScalar> :
Copy link
Member

Choose a reason for hiding this comment

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

Do you really "need" these rather than just having them on INumberVector?

static virtual TVector UnitX => { get; }
static virtual TVector UnitY => { get; }

TScalar X { get; }
Copy link
Member

Choose a reason for hiding this comment

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

X could be on IVector, since it wouldn't make sense to define a 0'd dimension vector >.>

documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
- For 3D Vectors, a Cross function which takes another vector and returns the cross product with our original vector.
- A static implementation of this function **must** be available as well.
- `+`, `-`, `*`, `/`, and `%` operators defined between two vectors of the same type which returns a vector which has had each operation applied component-wise.
- `+`, `-`, `*`, `/`, and `%` operators defined between a vector and a scalar value that matches the generic type which returns a vector which has had each operation applied component-wise with the scalar value. Both vector first and scalar first should be implemented.
Copy link
Contributor

Choose a reason for hiding this comment

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

scalar-vector only makes sense for *,/,% and im not sure scalar first makes sense for the latter two

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is component-wise so (4,5) + 5 = (9,10)
This isn't necessary, but more as an easy of use. If generally agreed we shouldn't have these I'll remove

documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
Comment on lines +205 to +213
- RoundToInt(Vector x)
- Returns `VectorNI`, where N matches the dimensionality of the vector
- **INFORMATIVE** This may require multiple methods depending on implementation
- FloorToInt(Vector x)
- Returns `VectorNI`, where N matches the dimensionality of the vector
- **INFORMATIVE** This may require multiple methods depending on implementation
- CeilingToInt(Vector x)
- Returns `VectorNI`, where N matches the dimensionality of the vector
- **INFORMATIVE** This may require multiple methods depending on implementation
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest specifying that these should take a type parameter for the particular int scalar type to use

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a reason to have one that does and one that does not, which matches Maxine's implementation currently (int can be done implicitly, the others need casts I believe). This is an mainly an implementation detail, that I want to leave up to whoever is implementing it.

documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
documentation/proposals/Proposal - Generic Math.md Outdated Show resolved Hide resolved
-and fix CreateFromPointNormal nomenclature
Making this a set of master types with obfuscated implmentation. Go For Perf
@Perksey
Copy link
Member

Perksey commented Nov 16, 2023

I'll merge this for simplicity in the meeting but make sure someone writes notes on the things we need to discuss a la the outstanding comments.

@Perksey Perksey merged commit da870ce into dotnet:proposal/silkx Nov 16, 2023
3 checks passed
Perksey added a commit that referenced this pull request Feb 12, 2024
* Update Proposal - Generation of Library Sources and PInvoke Mechanisms.md

* Update documentation/proposals/Proposal - Generation of Library Sources and PInvoke Mechanisms.md

* Update documentation/proposals/Proposal - Generation of Library Sources and PInvoke Mechanisms.md

* Update documentation/proposals/Proposal - Generation of Library Sources and PInvoke Mechanisms.md

* Update SilkX Proposals (#1792)

* Update SilkX Proposals

- Updated Pointer Proposal to match current implementation
- Add Generic Math Proposal based on Current work

* Added missing function proposals and fixing some language

* Implementing Review Feedback

* Major rewrite of Generic Math Proposal

-Slimmed it down though

* Remove Vector 5 note

* Addressing Review Comments

* More Review Comments

* Vector Transform Adjustments

-and fix CreateFromPointNormal nomenclature

* Remove  the Endians that escaped the first time

* Update for Rect/Box changes

* Added LH/RH Matrix Functions

* Box/Rect changes

Making this a set of master types with obfuscated implmentation. Go For Perf

* Update Proposal - Generation of Library Sources and PInvoke Mechanisms.md

* Bring back contexts - this was noted in WG review

* Add meeting notes to the generic math proposal

* Update Proposal - Generic Math.md

---------

Co-authored-by: Andrew Davis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants