# Broadcasting a function with qualifiers

**URL:** https://discourse.julialang.org/t/broadcasting-a-function-with-qualifiers/79192
**Category:** New to Julia
**Tags:** broadcast
**Created:** [April 7, 2022, 6:32pm UTC](https://discourse.julialang.org/t/broadcasting-a-function-with-qualifiers/79192 "2022-04-07T18:32:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ahmed](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@ahmed](https://discourse.julialang.org/u/ahmed)
#### Post date: [April 7, 2022, 6:32pm UTC](https://discourse.julialang.org/t/broadcasting-a-function-with-qualifiers/79192/1 "2022-04-07T18:32:24Z")

</div>

I’m trying to apply eigs over an array of matrices using broadcast. The thing is I want to apply eigs with certain qualifiers such as: eigs(A;nev=6,which=:SM,sigma=0.01).  
The general syntax for broadcast is however: broadcast(f,array). How do I use broadcast in my case? or is there another alternative?

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [April 7, 2022, 6:46pm UTC](https://discourse.julialang.org/t/broadcasting-a-function-with-qualifiers/79192/2 "2022-04-07T18:46:11Z")

</div>

What’s the problem of using

`eigs.(arrayOfMatrices;nev=6,which=:SM,sigma=0.01)` ?

(note the dot)

---

<div class="post-metadata">

### Author: ![skleinbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skleinbo/32/36080_2.png) [@skleinbo](https://discourse.julialang.org/u/skleinbo)
#### Post date: [April 8, 2022, 7:47am UTC](https://discourse.julialang.org/t/broadcasting-a-function-with-qualifiers/79192/3 "2022-04-08T07:47:33Z")

</div>

This discussion made me wonder how the dot deals with kwargs, because I always thought it lowered straightforwardly to `broadcast`. That’s not the case.

The dot notation in conjuction with `kwargs` creates a more involved broadcasted expression

```julia
julia> Meta.@lower f.([1,2];a=2)
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope'
1 ─ %1 = Base.vect(1, 2)
│ %2 = Base.broadcasted_kwsyntax
│ %3 = Core.tuple(:a)
│ %4 = Core.apply_type(Core.NamedTuple, %3)
│ %5 = Core.tuple(2)
│ %6 = (%4)(%5)
│ %7 = Core.kwfunc(%2)
│ %8 = (%7)(%6, %2, f, %1)
│ %9 = Base.materialize(%8)
└── return %9
))))

help?> Base.broadcasted_kwsyntax
  No documentation found.

  Base.Broadcast.broadcasted_kwsyntax is a Function.

  # 1 method for generic function "broadcasted_kwsyntax":
  [1] broadcasted_kwsyntax(f, args...; kwargs...) in Base.Broadcast at broadcast.jl:1297

julia> Base.broadcasted_kwsyntax(f, [1,2]; a=2)
Base.Broadcast.Broadcasted(#31, ([1, 2],))

```

So, yes, stick with the dot syntax 🙂
