Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in generic_vecnorms #23913

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Change in generic_vecnorms #23913

wants to merge 1 commit into from

Conversation

blas-ko
Copy link

@blas-ko blas-ko commented Sep 28, 2017

By default, generic_vecnorm of 1,2,Inf,-Inf,p, takes norm(v)^p (taking p as the general case which includes 1,2,Inf,-Inf). Normally, v is a Number so norm(v) just applies the

@inline vecnorm(x::Number, p::Real=2) = p == 0 ? (x==0 ? zero(abs(x)) : oneunit(abs(x))) : abs(x)

method.
This change is made because in some strange cases, v is not a Number but an Array and it's more convenient to take norm(v,p) instead of norm(v).

By default, `generic_vecnorm` of `1,2,Inf,-Inf,p`, takes `norm(v)^p` (taking `p` as the general case which includes 1,2,Inf,-Inf). Normally, `v` is a `Number` so `norm(v)` just applies the 
```julia @inline vecnorm(x::Number, p::Real=2) = p == 0 ? (x==0 ? zero(abs(x)) : oneunit(abs(x))) : abs(x) ```
method.
This change is made because in some _strange_ cases, `v` is not a `Number` but an `Array` and it's more convinient to take `norm(v,p)` instead of norm(v).
@blas-ko blas-ko changed the title Update generic.jl Change in generic_vecnorms Sep 28, 2017
@andreasnoack
Copy link
Member

I support this but see the previous discussion in #22945.

@andreasnoack andreasnoack added the linear algebra Linear algebra label Sep 28, 2017
@blas-ko
Copy link
Author

blas-ko commented Sep 29, 2017

I believe, from what I read from #22945, that it's a matter of taste wheather to define the inner norm as just norm(v) or norm(v,p). I still think it's more convenient to define the inner norm as norm(v,p) becuase in any vector space where you would like to have a p-norm of an element, you should expect your element to have a p-norm defined too.

Nevertheless, I could do a workaround of this problem by defining

norm(x,p::Real=2) = norm( norm.(x[:],p), p)

in my specific case (which has to do with TaylorSeries package).

Hope this helps at all in the discussion.

@andreasnoack
Copy link
Member

@blas-ko Could you give a more specific example of your use case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants