Skip to content

Commit 382e49f

Browse files
authored
Merge pull request #16 from laicasaane/master
Add functionality & restructure the project
2 parents ae36b09 + 3e7271a commit 382e49f

24 files changed

Lines changed: 315 additions & 8 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.csproj
2+
*.csproj.meta

Runtime/AssemblyInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using System.Runtime.CompilerServices;
2+
3+
[assembly: InternalsVisibleTo("Mathematics.Mathx.Tests")]

Runtime/AssemblyInfo.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"rootNamespace": "",
44
"references": [
55
"GUID:d8b63aba1907145bea998dd612889d6b",
6-
"GUID:343deaaf83e0cee4ca978e7df0b80d21",
76
"GUID:2bafac87e7f4b9b418d9448d219b01ab",
87
"GUID:2665a8d13d1b3f18800f46e256720795"
98
],

Runtime/Structs/byte2.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,5 +293,11 @@ public static partial class mathx
293293
/// When multiple elements are to be hashes together, it can more efficient to calculate and combine wide hash
294294
/// that are only reduced to a narrow uint hash at the very end instead of at every step.
295295
[MethodImpl(INLINE)] public static uint2 hashwide(byte2 v) => uint2(v.x, v.y) * uint2(0xEBD0D005u, 0x91475DF7u) + 0x55E84827u;
296+
297+
298+
/// <inheritdoc cref="subx(byte4, byte)"/>
299+
[MethodImpl(IL)] public static byte2 subx(this byte2 f, byte x) => new(x, f.y);
300+
/// <inheritdoc cref="suby(byte4, byte)"/>
301+
[MethodImpl(IL)] public static byte2 suby(this byte2 f, byte y) => new(f.x, y);
296302
}
297303
}

Runtime/Structs/byte3.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,5 +709,13 @@ public static partial class mathx
709709

710710
/// Returns a uint3 vector hash code of a byte3 vector.
711711
[MethodImpl(INLINE)] public static uint3 hashwide(byte3 v) => uint3(v.x, v.y, v.z) * uint3(0xFA3A3285u, 0xAD55999Du, 0xDCDD5341u) + 0x94DDD769u;
712+
713+
714+
/// <inheritdoc cref="subx(byte4, byte)"/>
715+
[MethodImpl(IL)] public static byte3 subx(this byte3 f, byte x) => new(x, f.y, f.z);
716+
/// <inheritdoc cref="suby(byte4, byte)"/>
717+
[MethodImpl(IL)] public static byte3 suby(this byte3 f, byte y) => new(f.x, y, f.z);
718+
/// <inheritdoc cref="subz(byte4, byte)"/>
719+
[MethodImpl(IL)] public static byte3 subz(this byte3 f, byte z) => new(f.x, f.y, z);
712720
}
713721
}

Runtime/Structs/byte4.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,5 +1859,15 @@ public static partial class mathx
18591859
/// When multiple elements are to be hashes together, it can more efficient to calculate and combine wide hash
18601860
/// that are only reduced to a narrow uint hash at the very end instead of at every step.
18611861
[MethodImpl(INLINE)] public static uint4 hashwide(byte4 v) => v * uint4(0xBC3B0A59u, 0x816EFB5Du, 0xA24E82B7u, 0x45A22087u) + 0xFC104C3Bu;
1862+
1863+
1864+
/// substitutes the component x
1865+
[MethodImpl(IL)] public static byte4 subx(this byte4 f, byte x) => new(x, f.y, f.z, f.w);
1866+
/// substitutes the component y
1867+
[MethodImpl(IL)] public static byte4 suby(this byte4 f, byte y) => new(f.x, y, f.z, f.w);
1868+
/// substitutes the component z
1869+
[MethodImpl(IL)] public static byte4 subz(this byte4 f, byte z) => new(f.x, f.y, z, f.w);
1870+
/// substitutes the component w
1871+
[MethodImpl(IL)] public static byte4 subw(this byte4 f, byte w) => new(f.x, f.y, f.z, w);
18621872
}
18631873
}

Runtime/Structs/color.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,5 +1627,15 @@ public static partial class mathx
16271627
[MethodImpl(INLINE)] public static float lineartogama(this float c) => c.pow(1 / 2.2f);
16281628
[MethodImpl(INLINE)] public static color gammatolinear(this color c) => new(c.x.gammatolinear(), c.y.gammatolinear(), c.z.gammatolinear(), c.w);
16291629
[MethodImpl(INLINE)] public static color lineartogama(this color c) => new(c.x.lineartogama(), c.y.lineartogama(), c.z.lineartogama(), c.w);
1630+
1631+
1632+
/// substitutes the component x
1633+
[MethodImpl(IL)] public static color subx(this color f, float x) => new(x, f.y, f.z, f.w);
1634+
/// substitutes the component y
1635+
[MethodImpl(IL)] public static color suby(this color f, float y) => new(f.x, y, f.z, f.w);
1636+
/// substitutes the component z
1637+
[MethodImpl(IL)] public static color subz(this color f, float z) => new(f.x, f.y, z, f.w);
1638+
/// substitutes the component w
1639+
[MethodImpl(IL)] public static color subw(this color f, float w) => new(f.x, f.y, f.z, w);
16301640
}
16311641
}

Runtime/mathx.common.double.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,5 +383,25 @@ public static partial class mathx
383383
[MethodImpl(IL)] public static double3 cycle(this double3 f, int n) => f.apply(cycle, n);
384384
/// applies a function to a double4 n times
385385
[MethodImpl(IL)] public static double4 cycle(this double4 f, int n) => f.apply(cycle, n);
386+
387+
388+
/// <inheritdoc cref="subx(double4, double)"/>
389+
[MethodImpl(IL)] public static double2 subx(this double2 f, double x) => new(x, f.y);
390+
/// <inheritdoc cref="suby(double4, double)"/>
391+
[MethodImpl(IL)] public static double2 suby(this double2 f, double y) => new(f.x, y);
392+
/// <inheritdoc cref="subx(double4, double)"/>
393+
[MethodImpl(IL)] public static double3 subx(this double3 f, double x) => new(x, f.y, f.z);
394+
/// <inheritdoc cref="suby(double4, double)"/>
395+
[MethodImpl(IL)] public static double3 suby(this double3 f, double y) => new(f.x, y, f.z);
396+
/// <inheritdoc cref="subz(double4, double)"/>
397+
[MethodImpl(IL)] public static double3 subz(this double3 f, double z) => new(f.x, f.y, z);
398+
/// substitutes the component x
399+
[MethodImpl(IL)] public static double4 subx(this double4 f, double x) => new(x, f.y, f.z, f.w);
400+
/// substitutes the component y
401+
[MethodImpl(IL)] public static double4 suby(this double4 f, double y) => new(f.x, y, f.z, f.w);
402+
/// substitutes the component z
403+
[MethodImpl(IL)] public static double4 subz(this double4 f, double z) => new(f.x, f.y, z, f.w);
404+
/// substitutes the component w
405+
[MethodImpl(IL)] public static double4 subw(this double4 f, double w) => new(f.x, f.y, f.z, w);
386406
}
387407
}

0 commit comments

Comments
 (0)