// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2014 Olga Diamanti // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "polyroots.h" #include template IGL_INLINE void igl::polyRoots(Eigen::Matrix &polyCoeff, //real or comples coefficients Eigen::Matrix, Eigen::Dynamic,1> &roots // complex roots (double or float) ) { // degree int n = polyCoeff.rows() - 1; Eigen::Matrix d (n,1); d = polyCoeff.tail(n)/polyCoeff(0); Eigen::Matrix I; I.setIdentity(n-1,n-1); Eigen::Matrix z; z.setZero(n-1,1); Eigen::Matrix a(n,n); a<<-d.transpose(),I,z; roots = a.eigenvalues(); } #ifdef IGL_STATIC_LIBRARY // Explicit template specialization template void igl::polyRoots, double>(Eigen::Matrix, -1, 1, 0, -1, 1>&, Eigen::Matrix, -1, 1, 0, -1, 1>&); template void igl::polyRoots(Eigen::Matrix&, Eigen::Matrix, -1, 1, 0, -1, 1>&); #endif