libigl v2.5.0
Loading...
Searching...
No Matches
LinSpaced.h File Reference

This function is not intended to be a permanent function of libigl. More...

#include <Eigen/Core>

Go to the source code of this file.

Namespaces

namespace  igl
 

Functions

template<typename Derived >
Derived igl::LinSpaced (typename Derived::Index size, const typename Derived::Scalar &low, const typename Derived::Scalar &high)
 Replacement for Eigen::DenseBase::LinSpaced.
 

Detailed Description

This function is not intended to be a permanent function of libigl.

Rather it is a "drop-in" workaround for documented bug in Eigen: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1383

Replace:

Eigen::VectorXi::LinSpaced(size,low,high);

With:

igl::LinSpaced<Eigen::VectorXi>(size,low,high);

Specifcally, this version will always return an empty vector if size==0, regardless of the values for low and high. If size != 0, then this simply returns the result of Eigen::Derived::LinSpaced.

Until this bug is fixed, we should also avoid calls to the member function .setLinSpaced. This means replacing:

a.setLinSpaced(size,low,high);

with

a = igl::LinSpaced<decltype(a) >(size,low,high);