Opened 12 years ago
Closed 12 years ago
#1746 closed enhancement (fixed)
[with patch, positive review] add p-norm as a method to vectors (probably very easy)
Reported by: | was | Owned by: | was |
---|---|---|---|
Priority: | major | Milestone: | sage-2.10.1 |
Component: | linear algebra | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | 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 12 years ago by
- Type changed from defect to enhancement
comment:2 Changed 12 years ago by
comment:3 Changed 12 years ago by
In the above example it should be
linalg.norm(v.numpy(),5)
comment:4 Changed 12 years ago by
- Milestone changed from sage-2.10.1 to sage-2.10
- Summary changed from add p-norm as a method to vectors (probably very easy) to [with patch] add p-norm as a method to vectors (probably very easy)
Changed 12 years ago by
comment:5 Changed 12 years ago by
does this also work for matrices? matrix norms are at least equally important!
comment:6 Changed 12 years ago by
What is the defn of matrix p-norms? Is it the same?
comment:7 Changed 12 years ago by
- Summary changed from [with patch] add p-norm as a method to vectors (probably very easy) to [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 12 years ago by
- Summary changed from [with patch, needs review] add p-norm as a method to vectors (probably very easy) to [with patch, positive review] add p-norm as a method to vectors (probably very easy)
comment:9 Changed 12 years ago by
- Resolution set to fixed
- Status changed from new to closed
Merged in Sage 2.10.1.alpha0
for RDF and CDF vectors
3.0773848853940629