Opened 15 years ago
Closed 15 years ago
#1746 closed enhancement (fixed)
[with patch, positive review] add p-norm as a method to vectors (probably very easy)
Reported by: | William Stein | Owned by: | William Stein |
---|---|---|---|
Priority: | major | Milestone: | sage-2.10.1 |
Component: | linear algebra | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
On Jan 10, 2008 12:17 AM, vgermrk <vgermrk@googlemail.com> wrote: > > [Sorry for asking so much "Is there a ... function in Sage?" - > Questions.] > > But: Is there a native way to compute the p-Norm (e.g. euclidean oder > maximum norm) of a vector? > There is no built in function, but we can write one easily: def pnorm(v, p): return sum([a^p for a in v])^(1/p) Then: sage: pnorm(vector([1,2,3]), 5) 276^(1/5) sage: pnorm(vector(RDF, [1,2,3]), 5) 3.07738488539 sage: var('a b c d p') sage: pnorm(vector([a, b, c, d]), p) (d^p + c^p + b^p + a^p)^(1/p) -- William
Attachments (1)
Change History (10)
comment:1 Changed 15 years ago by
Type: | defect → enhancement |
---|
comment:2 Changed 15 years ago by
comment:4 Changed 15 years ago by
Milestone: | sage-2.10.1 → sage-2.10 |
---|---|
Summary: | add p-norm as a method to vectors (probably very easy) → [with patch] add p-norm as a method to vectors (probably very easy) |
Changed 15 years ago by
Attachment: | 1746.patch added |
---|
comment:5 Changed 15 years ago by
does this also work for matrices? matrix norms are at least equally important!
comment:7 Changed 15 years ago by
Summary: | [with patch] add p-norm as a method to vectors (probably very easy) → [with patch, needs review] add p-norm as a method to vectors (probably very easy) |
---|
I agree that matrix norms are important. However, unlike the case of vectors, where the p-norm is rather universally agreed upon, there are a bunch of different definitions for norms on matrices, see http://en.wikipedia.org/wiki/Matrix_norm There are at least 3 different things denoted as p-norm there.
I think it's important for us to do this, but trickier than the vector case, so I've made it into track #1763.
In the meantime, it would be great if someone reviewed the current patch.
comment:8 Changed 15 years ago by
Summary: | [with patch, needs review] add p-norm as a method to vectors (probably very easy) → [with patch, positive review] add p-norm as a method to vectors (probably very easy) |
---|
comment:9 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Merged in Sage 2.10.1.alpha0
for RDF and CDF vectors
3.0773848853940629