[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] Matrix2i mean
- From: Petr Kubánek <pkubanek@xxxxxxxxx>
- Date: Mon, 04 Nov 2019 16:35:15 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:date:mime-version :content-transfer-encoding; bh=8zdCTTwdl8ZWu5rJmPqBpArw+ElRHDeIiPlb7NuF6TE=; b=HE7POqoPNMngyYNUjZG9bdkzPZ0s6hg1wxBaK2mvq6vFGxzqLrJuYhVesaj5v/Phiu EPxDhikMEavKxQMYRuL78kdDbw81DSaQRey2x4QHG6UWoSQ+uH8hgiUunAEgVZ7BAt6I PgjtA4CIFlCQn1v9xztz8DKIBpztlgjkN+EjuZx343Jxn8XkC+8OjWz/2zCvDT1YsMRh qX3kc2JCbdsc9vzVQA56tGISJApAPh+kIihSI2G79ySpQLt2py1btNJBMB5R9cpyxc+7 JQF98M0OMHCF/RsScPRr75x0fSQfb0KbBNtmp5KnVOjXbHd3ubA6kVYElfRlvWJGyKme WAog==
Hi,
calculating mean on int matrix fails to produce expected results - see
below. I noticed
https://eigen.tuxfamily.org/bz/show_bug.cgi?id=426
which is a bit similar, but different.
Obviously all similar reduxes (sum, prod) fails as well. Is there a way
how to change type used as the internal storage and result for sum.
mean calculations?
Thanks
--
Petr Kubánek
Software Engineer - Telescope Control System
Large Binocular Telescope Observatory
580D Steward Observatory
933 N Cherry Avenue
Tucson, AZ 85721
This results in:
-4095 12288.6
12288.5 12288.6
#include <Eigen/Eigen>
#include <iostream>
int main(int, char **)
{
Eigen::Matrix<int16_t, 2, 2> m;
m <<
INT16_MAX / 2.0, INT16_MAX,
2, 2;
double mean = (INT16_MAX / 2.0 + INT16_MAX + 2 + 2) / 4.0;
std::cout << m.mean() << " " << mean << std::endl;
Eigen::Matrix<double, 2, 2> md = m.cast<double>();
std::cout << md.mean() << " " << mean << std::endl;
}