Giter Club home page Giter Club logo

Comments (5)

redorav avatar redorav commented on May 25, 2024

Hi @apple-phi it's just an omission really, not by design. I use double vectors less often than I do float vectors and I've dedicated less attention to them. They are meant to have the same interface, I just haven't had the time and people don't seem to be that interested in them either.

The complexity with double is that they have two implementations, one before AVX and the other with AVX. It takes time to implement and verify them. I can see that there are several basic functions that haven't been implemented yet as you say. Reference implementations for them can be found in hlsl++_vector_float, for example

inline n128 _hlslpp_sin_ps(n128 x)
{
	static const n128 sin_c1 = f4_1;
	static const n128 sin_c3 = _hlslpp_set1_ps(-1.6665578e-1f);
	static const n128 sin_c5 = _hlslpp_set1_ps(8.3109378e-3f);
	static const n128 sin_c7 = _hlslpp_set1_ps(-1.84477486e-4f);

	// Range reduction (into [-pi, pi] range)
	// Formula is x = x - round(x / 2pi) * 2pi

	x = _hlslpp_subm_ps(x, _hlslpp_round_ps(_hlslpp_mul_ps(x, f4_inv2pi)), f4_2pi);

	n128 gtpi2 = _hlslpp_cmpgt_ps(x, f4_pi2);
	n128 ltminusPi2 = _hlslpp_cmplt_ps(x, f4_minusPi2);

	n128 ox = x;

	// Use identities/mirroring to remap into the range of the minimax polynomial
	x = _hlslpp_sel_ps(x, _hlslpp_sub_ps(f4_pi, ox), gtpi2);
	x = _hlslpp_sel_ps(x, _hlslpp_sub_ps(f4_minusPi, ox), ltminusPi2);

	n128 x2 = _hlslpp_mul_ps(x, x);
	n128 result;
	result = _hlslpp_madd_ps(x2, sin_c7, sin_c5);
	result = _hlslpp_madd_ps(x2, result, sin_c3);
	result = _hlslpp_madd_ps(x2, result, sin_c1);
	result = _hlslpp_mul_ps(result, x);
	return result;
}

That can work as a starting point. If there's further interest and this would be useful to you, I can start slowly implementing and adding some of these to the double class.

from hlslpp.

apple-phi avatar apple-phi commented on May 25, 2024

@redorav Thanks for the reply! I'm pretty sure the only ones I'm missing that I need for my project is a cross product and normalisation. I'll probably just use a naive non-SIMD self-implementation for now but it would be great if you could add those into the library when you get the chance :)

from hlslpp.

redorav avatar redorav commented on May 25, 2024

@apple-phi I added normalization as it was simple to do, I'll see if I can find the time to add the cross product soon

from hlslpp.

apple-phi avatar apple-phi commented on May 25, 2024

@redorav Amazing, thank you! Lmk if you get round to doing the cross product :)

from hlslpp.

redorav avatar redorav commented on May 25, 2024

Implemented in 24c3168

from hlslpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.