Skip to content

Commit ea31887

Browse files
committed
Also add fast mul by i,-i to cpp
1 parent cd07b9b commit ea31887

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

include/nbl/builtin/hlsl/complex.hlsl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,24 @@ namespace nbl
1717
namespace hlsl
1818
{
1919

20-
template<class T>
21-
using complex_t = std::complex<T>;
20+
template<typename Scalar>
21+
using complex_t = std::complex<Scalar>;
22+
23+
// Fast mul by i
24+
template<typename Scalar>
25+
complex_t<Scalar> rotateLeft(NBL_CONST_REF_ARG(complex_t<Scalar>) value)
26+
{
27+
complex_t<Scalar> retVal = { -value.imag(), value.real() };
28+
return retVal;
29+
}
30+
31+
// Fast mul by -i
32+
template<typename Scalar>
33+
complex_t<Scalar> rotateRight(NBL_CONST_REF_ARG(complex_t<Scalar>) value)
34+
{
35+
complex_t<Scalar> retVal = { value.imag(), -value.real() };
36+
return retVal;
37+
}
2238

2339
}
2440
}

0 commit comments

Comments
 (0)