Lesson15 Reductions
来源:互联网 发布:梦龙网络计划2016 编辑:程序博客网 时间:2024/05/21 07:50
In Eigen, a reduction is a function taking a matrix or array, and returning a single scalar value. One of the most used reductions is .sum() , returning the sum of all the coefficients inside a given matrix or array.
#include <iostream>
#include <Eigen/Dense>
using namespace std;
int main()
{
Eigen::Matrix2d mat;
mat << 1, 2,
3, 4;
cout << "Here is mat.sum(): " << mat.sum() << endl;
cout << "Here is mat.prod(): " << mat.prod() << endl;
cout << "Here is mat.mean(): " << mat.mean() << endl;
cout << "Here is mat.minCoeff(): " << mat.minCoeff() << endl;
cout << "Here is mat.maxCoeff(): " << mat.maxCoeff() << endl;
cout << "Here is mat.trace(): " << mat.trace() << endl;
}
Here is mat.sum(): 10Here is mat.prod(): 24Here is mat.mean(): 2.5Here is mat.minCoeff(): 1Here is mat.maxCoeff(): 4Here is mat.trace(): 5
The trace of a matrix, as returned by the function trace()
, is the sum of the diagonal coefficients and can equivalently be computed a.diagonal().sum()
.
0 0
- Lesson15 Reductions
- SQLi Labs Lesson15
- Faster Parallel Reductions on Kepler
- 【西西学FPGA】Lesson15 sobel
- 孙鑫lesson15 多线程与聊天室
- Princeton Algorithms: Part 2 [week 7: Reductions]
- NeHe教程Qt实现——lesson15
- 《Algorithms》第7章:Linear programming and reductions 学习笔记
- 读书笔记:Hyperbolic reductions for Einstein's equations(Helmut Friedrich 1996)
- [MFC学习笔记]--lesson15多线程与聊天室程序的设计
- Windows程序设计__孙鑫C++Lesson15《多线程与聊天室程序创建》
- C语言学习笔记 lesson15&16 函数2指针的偏移
- Delete File java 代码
- [技术讨论]都用敏捷么,为什么要用,怎样才对?
- TCP的三次握手,四次挥手
- div自由拖拽
- HTML接收?号后参数和js获取工程名
- Lesson15 Reductions
- 【Android】多图选择器(支持图片预览 高效加载不怕OOM)
- 对给定音频文件“testshort.wav”,用matlab输出它的波形【学生创新实验室联合纳新测试题】
- iOS单例
- Java内存管理原理及内存区域详解
- MySQL数据库的分区表、存储过程、event定时任务的创建
- NSString基础知识
- Freemarker遍历键值为对象的map
- InputStream 转为 Byte