Skip to Content
Java数据科学实战
book

Java数据科学实战

by Michael R. Brzustowicz, PhD
January 2020
Intermediate to advanced
202 pages
5h 41m
Chinese
Posts & Telecom Press
Content preview from Java数据科学实战
36
|
第
2
章
2.2.2
 转置
对矩阵或向量进行
转置
(
transpose
),类似于把它沿着从左上角到右下角的对角线翻转过
来。向量
x
的转置记作
x
T
,矩阵
A
的转置记作
A
T
。许多情况下没有必要计算向量的转置,
因为在实现时,
RealVector
类与
RealMatrix
类的方法已考虑了向量转置的需要。除非向量
以矩阵形式表示,否则其转置是未定义的。于是,
m
×
1
列向量的转置是新的大小为
1
×
m
的行向量矩阵。
x
T
=
(
x
1
,
x
2
,
⋯
,
x
m
)
若确实需要对向量进行转置,则可以直接把数据插入到
RealMatrix
实例中。采用元素值为
double
型的一维数组作为参数,提供给
Array2DRowRealMatrix
类,可以创建
m
行
1
列的矩
阵,其值由
double
型数组提供。把列向量进行转置将返回
1
行
m
列的矩阵。
double
[] data = {1.2, 3.4, 5.6};
RealMatrix columnVector =
new
Array2DRowRealMatrix(data);
System.out.println(columnVector);
/* {{1.2}, {3.4}, {5.6}} */
RealMatrix rowVector = columnVector.transpose();
System.out.println(rowVector);
/* {{1.2, 3.4, 5.6}} */
对
m
×
n
矩阵进行转置,结果是
n
×
m
矩阵。简单来说,就是把行与列的索引
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

云安全实用指南

云安全实用指南

Chris Dotson
Kafka权威指南

Kafka权威指南

Neha Narkhede, Gwen Shapira, Todd Palino

Publisher Resources

ISBN: 9787115533302