Opened 13 years ago

Closed 13 years ago

#6301 closed enhancement (fixed)

[with patch, positive review] implement the Hadamard product of two matrices

Reported by: ncalexan Owned by: William Stein
Priority: minor Milestone: sage-4.1.1
Component: linear algebra Keywords: elementwise Hadamard matrix product
Cc: Rob Beezer, ylchapuy Merged in: sage-4.1.1.alpha0
Authors: Rob Beezer Reviewers: Jason Grout
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

That is, given a matrix A and another matrix B (of the same dimensions), form C such that C[i, j] = A[i, j] * B[i, j].

Attachments (1)

trac_6301_elementwise_matrix_product.patch (11.5 KB) - added by Rob Beezer 13 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 13 years ago by Rob Beezer

Cc: Rob Beezer added

comment:2 Changed 13 years ago by Rob Beezer

Authors: Rob Beezer
Cc: ylchapuy added
Keywords: elementwise added
Summary: implement the Hadamard product of two matrices[with patch, needs review] implement the Hadamard product of two matrices
Type: defectenhancement

Patch overview:

elementwise_product() in matrix2.pyx checks inputs for proper sizes, and coerces base rings, etc.

Then two versions of _elementwise_product() (in matrix_dense.pyx and matrix_sparse.pyx) take over and do the actual work in what should be a fairly efficient manner, given the generality implied.

More efficient implementations are certainly possible for more specialized classes. The intent here is to begin with a correct and general implementation that is moderately efficient, primarily to make the functionality available in Sage.

Changed 13 years ago by Rob Beezer

comment:3 Changed 13 years ago by Jason Grout

Summary: [with patch, needs review] implement the Hadamard product of two matrices[with patch, positive review] implement the Hadamard product of two matrices

Nice work! This all looks great. Doctests in these files pass as well. Positive review.

comment:4 Changed 13 years ago by Jason Grout

Reviewers: Jason Grout

comment:5 Changed 13 years ago by Jason Grout

Milestone: sage-featuresage-4.1.1

comment:6 Changed 13 years ago by Minh Van Nguyen

Merged in: sage-4.1.1.alpha0
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.