Re: [eigen] Best way of initializing a matrix of fixed size

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Strange, it usually compiles to trivial code, e.g.:

void foo(Matrix4f &m)
{
  m <<  1,  2,  3,  4,
        5,  6,  7,  8,
        9, 10, 11, 12,
       13, 14, 15, 16;
}

compiles to:

movaps LCPI0_0(%rip), %xmm0    ## xmm0 = [1065353216,1084227584,1091567616,1095761920]
movups %xmm0, (%rdi)
movaps LCPI0_1(%rip), %xmm0    ## xmm0 = [1073741824,1086324736,1092616192,1096810496]
movups %xmm0, 16(%rdi)
movaps LCPI0_2(%rip), %xmm0    ## xmm0 = [1077936128,1088421888,1093664768,1097859072]
movups %xmm0, 32(%rdi)
movaps LCPI0_3(%rip), %xmm0    ## xmm0 = [1082130432,1090519040,1094713344,1098907648]
movups %xmm0, 48(%rdi)
popq %rbp
retq

make sure you compiled with full optimization. If so, check the respective assembly.

gael

On Tue, Mar 7, 2017 at 1:57 PM, Matthieu Brucher <matthieu.brucher@xxxxxxxxx> wrote:
Hi,

I'm wondering what is the best way of initializing a 4x4 matrix. I'm currently using the comma initializer, but it shows up quite high on a valgrind profile compared to taking the inverse of the same matrix or preprocessing the coeffs (pow, ln...).
I'm using Eigen 3.2.4, but I can upgrade.

Cheers,

Matthieu
--
Information System Engineer, Ph.D.
Blog: http://blog.audio-tk.com/
LinkedIn: http://www.linkedin.com/in/matthieubrucher



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/