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

Dynamic Array of a fixed sized Matrix #88

Open
chkone opened this issue May 18, 2020 · 2 comments
Open

Dynamic Array of a fixed sized Matrix #88

chkone opened this issue May 18, 2020 · 2 comments

Comments

@chkone
Copy link

chkone commented May 18, 2020

Could you help me to clarify this behavior:

using Mat22f = enoki::Matrix< f32, 2 >;
using Mat22fBuffer = enoki::DynamicArray< enoki::Packet< Mat22f, 2 > >; // With 2
Mat22fBuffer x, y;
y = x;

// Compile time error:
array_generic.h(464,59): error C2440: '<function-style-cast>': cannot convert from 'enoki::Array<eMV::f32,2>' to 'enoki::Matrix<eMV::f32,2>'
array_generic.h(414,1): message : No constructor could take the source type, or constructor overload resolution was ambiguous
array_generic.h(344): message : see reference to function template instantiation 'void enoki::StaticArrayImpl<Value_,2,false,enoki::Packet<Value_,2>,int>::assign_<eMV::Mat22f&,0,1>(T,std::integer_sequence<size_t,0,1>)' being compiled
1>        with
1>        [
1>            Value_=eMV::Mat22f,
1>            T=eMV::Mat22f &
1>        ]

With:

using Mat22f = enoki::Matrix< f32, 2 >;
using Mat22fBuffer = enoki::DynamicArray< enoki::Packet< Mat22f, 2 > >; // With 1
Mat22fBuffer x, y;
y = x;

Compile with no problem.

@Speierers
Copy link
Member

Speierers commented May 18, 2020

What will be the use of this Mat22Buffer type?

To perform operations on an "array" of matrices, what you want is:

using MyMat22 = enoki::Matrix<enoki::DynamicArray<enoki::Packet<float, PACKET_WIDTH>>, 2>;

here using a Structure of Arrays (SoA) instead of an Array of Structures (AoS).

@chkone
Copy link
Author

chkone commented May 18, 2020

This is from a code generation.
From "Basic type" & enoki types {int32_t, int64_t, float, enoki::Array<float, 2>, enoki::Array<float, 3>, ..., } based on the context I generate a dynamic version of it.
Like

template < typename Type >
constexpr size_t PacketSize = enoki::max_packet_size/sizeof( Type );

Generated:
using TypeBuffer = enoki::DynamicArray<enoki::Packet<Type, PacketSize< Type > == 0 ? 1 : PacketSize< Type > >;

My understanding was, that will be flatten internally and keeping the type for operation during the unroll of the template expression (for example multiplication).
I will rewrite the code-gen if it's "as design".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants