C++_Eigen函数库用法笔记——Matrix and Vector Arithmetic
- Addition and subtraction
 
- Scalar multiplication and division
 - Transposition
 
- Matrix-matrix and matrix-vector multiplication
 
- Trace(求迹的和)
 
- Addition and subtraction
- binary operator + as in 
a+b - binary operator - as in 
a-b - unary operator - as in 
-a - compound operator += as in 
a+=b - compound operator -= as in 
a-=b#include <iostream>#include <Eigen/Dense>using namespace Eigen;int main(){Matrix2d a;a << 1, 2,3, 4;MatrixXd b(2,2);b << 2, 3,1, 4;std::cout << "a + b =\n" << a + b << std::endl;std::cout << "a - b =\n" << a - b << std::endl;std::cout << "Doing a += b;" << std::endl;a += b;std::cout << "Now a =\n" << a << std::endl;Vector3d v(1,2,3);Vector3d w(1,0,0);std::cout << "-v + w - v =\n" << -v + w - v << std::endl;}a + b =
3 5
4 8
a - b =
-1 -1
2 0
Doing a += b;
Now a =
3 5
4 8
-v + w - v =
-1
-4
-6 
 - binary operator + as in 
 - Scalar multiplication and division
- binary operator * as in
matrix*scalar - binary operator * as in 
scalar*matrix - binary operator / as in 
matrix/scalar - compound operator *= as in 
matrix*=scalar - compound operator /= as in 
matrix/=scalar#include <iostream>#include <Eigen/Dense>using namespace Eigen;int main(){Matrix2d a;a << 1, 2,3, 4;Vector3d v(1,2,3);std::cout << "a * 2.5 =\n" << a * 2.5 << std::endl;std::cout << "0.1 * v =\n" << 0.1 * v << std::endl;std::cout << "Doing v *= 2;" << std::endl;v *= 2;std::cout << "Now v =\n" << v << std::endl;}a * 2.5 =
2.5 5
7.5 10
0.1 * v =
0.1
0.2
0.3
Doing v *= 2;
Now v =
2
4
6 
 - TranspositionMatrixXcf a = MatrixXcf::Random(2,2);cout << "Here is the matrix a\n" << a << endl;cout << "Here is the matrix a^T\n" << a.transpose() << endl;Here is the matrix a
(-0.211,0.68) (-0.605,0.823)
(0.597,0.566) (0.536,-0.33)
Here is the matrix a^T
(-0.211,0.68) (0.597,0.566)
(-0.605,0.823) (0.536,-0.33) 
a = a.transpose() does not replace a with its transpose- Matrix-matrix and matrix-vector multiplication
- binary operator * as in 
a*b - compound operator *= as in 
a*=b(this multiplies on the right:a*=bis equivalent toa = a*b#include <iostream>#include <Eigen/Dense>using namespace Eigen;int main(){Matrix2d mat;mat << 1, 2,3, 4;Vector2d u(-1,1), v(2,0);std::cout << "Here is mat*mat:\n" << mat*mat << std::endl;std::cout << "Here is mat*u:\n" << mat*u << std::endl;std::cout << "Here is u^T*mat:\n" << u.transpose()*mat << std::endl;std::cout << "Here is u^T*v:\n" << u.transpose()*v << std::endl;std::cout << "Here is u*v^T:\n" << u*v.transpose() << std::endl;std::cout << "Let's multiply mat by itself" << std::endl;mat = mat*mat;std::cout << "Now mat is mat:\n" << mat << std::endl;}Here is mat*mat:
7 10
15 22
Here is mat*u:
1
1
Here is u^T*mat:
2 2
Here is u^T*v:
-2
Here is u*v^T:
-2 -0
2 0
Let's multiply mat by itself
Now mat is mat:
7 10
15 22 
 - binary operator * as in 
 
- Trace(求迹的和)
#include <iostream>#include <Eigen/Dense>using namespace std;int main(){Eigen::Matrix2d mat;mat << 1, 2,3, 4;cout << "Here is mat.trace(): " << mat.trace() << endl;}Here is mat.trace(): 5
 
C++_Eigen函数库用法笔记——Matrix and Vector Arithmetic的更多相关文章
- C++_Eigen函数库用法笔记——The Array class and Coefficient-wise operations
		
The advantages of Array Addition and subtraction Array multiplication abs() & sqrt() Converting ...
 - C++_Eigen函数库用法笔记——Block Operations
		
Using block operations rvalue, i.e. it was only read from lvalues, i.e. you can assign to a block Co ...
 - C++_Eigen函数库用法笔记——Advanced Initialization
		
The comma initializer a simple example join and block initialize join two row vectors together ini ...
 - PHP中正则替换函数preg_replace用法笔记
		
今天应老板的需求,需要将不是我们的页面修改一个链接,用js+iframe应该也能实现,但是我想尝试一下php实现方法. 首先你得先把别人的页面download到你的php中,实现方法可以用curl, ...
 - 菜鸟Python学习笔记第一天:关于一些函数库的使用
		
2017年1月3日 星期二 大一学习一门新的计算机语言真的很难,有时候连函数拼写出错查错都能查半天,没办法,谁让我英语太渣. 关于计算机语言的学习我想还是从C语言学习开始为好,Python有很多语言的 ...
 - 转: ES6异步编程: co函数库的含义与用法
		
转: ES6异步编程: co函数库的含义与用法 co 函数库是著名程序员 TJ Holowaychuk 于2013年6月发布的一个小工具,用于 Generator 函数的自动执行. 比如,有一个 Ge ...
 - makefile笔记10 - makefile 函数库文件
		
函数库文件也就是对 Object 文件(程序编译的中间文件)的打包文件.在 Unix 下,一般是由命令"ar"来完成打包工作. 一.函数库文件的成员 一个函数库文件由多个文件组成. ...
 - OpenCV 学习笔记03 boundingRect、minAreaRect、minEnclosingCircle、boxPoints、int0、circle、rectangle函数的用法
		
函数中的代码是部分代码,详细代码在最后 1 cv2.boundingRect 作用:矩形边框(boundingRect),用于计算图像一系列点的外部矩形边界. cv2.boundingRect(arr ...
 - python3.4学习笔记(二十) python strip()函数 去空格\n\r\t函数的用法
		
python3.4学习笔记(二十) python strip()函数 去空格\n\r\t函数的用法 在Python中字符串处理函数里有三个去空格(包括'\n', '\r', '\t', ' ')的函数 ...
 
随机推荐
- python数字图像处理(14):高级滤波
			
本文提供更多更强大的滤波方法,这些方法放在filters.rank子模块内. 这些方法需要用户自己设定滤波器的形状和大小,因此需要导入morphology模块来设定. 1.autolevel 这个词在 ...
 - ant  exec
			
http://ant.apache.org/manual/Tasks/exec.html Exec Description Executes a system command. When the os ...
 - Java环境解析apk文件信息
			
概述:Java解析apk文件,获取apk文件里的包名,版本号,图标文件等; 功能:可以提供给windows和linux平台使用; 原理:利用aapt.exe或者aapt这些anroid平台解析apk文 ...
 - 对于JAVA课程的期望
			
对于JAVA课程的期望 我对于JAVA这门课程最初的了解可能来自于学长学姐的描述,或者是选课指南上简单的课程名称,那个时候的JAVA,对我来说遥远而又陌生,显得那么高大上,但是一转眼自己马上就要结束大 ...
 - 高层次综合(HLS)-简介
			
本文是我近段时间的学习总结,主要参考了Xilinx的技术文档以及部分网上其他资料.文档主要包括ug998<Introduction to FPGA Design Using High-Level ...
 - FlipView For Xamarin.Form 之 IOS
			
之前写过两篇博文 是关于 Android 和 Windows Phone 下的 FlipView 的实现. 上上周,有个印度佬通过 GitHub 找到我, 问我有没有打算个 ios 端的,还说比较了相 ...
 - 利用php实现文件迁移重命名
			
首先表明,这是一个悲伤的故事. 暑假来临,学校安排我们到某软件外包公司实习,想想不用面试也是蛮方便的,可以借此机会向大牛学习学习,虽然没有工资(据说学校还交了600块的保险),但想想还是蛮期待的,但真 ...
 - 成都普华永道税务开发的offer
			
首先这是一个.net税务开发的offer,我是做开发的. 有没有人在成都普华永道的,最近收到普华永道的offer,如果有的话请联系我.想知道里面的情况.最想知道里面的加班情况,薪资还是有点诱惑的.毕竟 ...
 - 《TCP/IP详解卷1:协议》第4章 ARP:地址解析协议-读书笔记
			
章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...
 - T4模板在项目中的使用
			
建立T4模板方法:右键添加新项->文本模板 使用T4模板生成Dal层代码如下: <#@ template language="C#" debug="false ...