Reply to topic

Round, ceil, floor in eigen

audioguy
Registered Member
Posts
11
Karma
0

Round, ceil, floor in eigen

Thu Jul 18, 2013 1:49 pm
There is a 3 year old thread about whether these functions are implemented in eigen. I wanted to know if anyone has done this in the mean time?
jitseniesen
Registered Member
Posts
186
Karma
2

Re: Round, ceil, floor in eigen

Thu Jul 18, 2013 2:23 pm
I'm afraid nothing has been done (as far as I know).
audioguy
Registered Member
Posts
11
Karma
0

Re: Round, ceil, floor in eigen

Fri Jul 19, 2013 10:44 am
So the easiest way to get the rounded value of the coefficients of an array is to loop through them and use the ceil from math.h?
jitseniesen
Registered Member
Posts
186
Karma
2

Re: Round, ceil, floor in eigen

Fri Jul 19, 2013 11:23 am
An alternative is to use .unaryExpr(), as in:
Code: Select all
matrix.unaryExpr(std::ptr_fun<double,double>(std::floor))

I think you need to specify the types to select the correct overload of the floor function, unfortunately.
audioguy
Registered Member
Posts
11
Karma
0

Re: Round, ceil, floor in eigen

Fri Jul 19, 2013 12:06 pm
I did this. It worked ;) Dont know about efficiency though

Code: Select all
ArrayXd time(N*N*N);

//.....

for ( icounter = 0 ; icounter < N*N*N ; icounter++)
      time(icounter) = ceil(time(icounter));

 
Reply to topic

Bookmarks



Who is online

Registered users: Alexa [Bot], asevens, Baidu [Spider], Bing [Bot], bjoernbalazs, Exabot [Bot], Google [Bot], GordieGii, Hans, isadora, koriun, lueck, Majestic-12 [Bot], mmistretta, MSNbot Media, nezumi, Yahoo [Bot]