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数据科学实战
42
|
第
2
章
/* matrixA与matrixB都是
n
× 1的列向量 */
RealMatrix outerProduct = matrixA.multiply(matrixB.transpose());
2.2.9
 逐项积
逐项积也称作
Hadamard
积或者
Schur
积。逐项积是把向量的每个分量与另一向量的对应分
量相乘,两个向量必须有相同的维数,所产生的结果向量也有着与这两个向量相同的维数。
a
∘
b
=
(
a
1
b
1
,
a
2
b
2
,
…
,
a
n
b
n
)
RealVector.ebeMultiply(RealVector)
方法可以完成这个运算,其中
ebe
是
逐项
(
element
by element
)的缩写。
/* 计算向量
a
与向量
b
的逐项积 */
RealVector vectorATimesVectorB = vectorA.ebeMultiply(vectorB);
采用
RealVector.ebeDivision(RealVector)
方法可以完成类似的逐项除运算。
不要将逐项积与矩阵积混淆(包括内积与外积)。在多数算法中需要矩阵积。
然而,逐项积也会有派上用场的时候,比如需要把向量用另一权值向量进行
缩放时。
目前,在
Apache Commons Math
矩阵乘法中,并没有实现
Hadamard
积。但是,用下面的
简单方法可以很容易地实现它:
public class MatrixUtils
{
public static
RealMatrix ebeMultiply(RealMatrix ...
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