# Function name like ‘SMatrix{N,N}’

**URL:** <https://discourse.julialang.org/t/function-name-like-smatrix-n-n/107309>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 8, 2023, 2:34am UTC](https://discourse.julialang.org/t/function-name-like-smatrix-n-n/107309 "2023-12-08T02:34:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Post date:** [December 8, 2023, 2:34am UTC](https://discourse.julialang.org/t/function-name-like-smatrix-n-n/107309/1 "2023-12-08T02:34:31Z")

</div>

The following is a script from [here](https://github.com/JuliaArrays/StaticArrays.jl/blob/master/perf/README_benchmarks.jl). We see code

```julia
SA = SMatrix{N,N}(A)

```

Is it ok for a function name to contain the curly brackets? I guess ‘SMatrix{N,N}’ is a function, right?

```julia
using BenchmarkTools
using LinearAlgebra
using StaticArrays

add!(C, A, B) = (C .= A .+ B)

function simple_bench(N, T=Float64)
    A = rand(T,N,N)
    A = A'*A
    B = copy(A)
    SA = SMatrix{N,N}(A)
    MA = MMatrix{N,N}(A)
    MB = copy(MA)

    print("""
============================================
    Benchmarks for $N×$N $T matrices
============================================
""")
    ops = [
           ("Matrix multiplication ", *, (A, A), (SA, SA)),
           ("Matrix multiplication (mutating) ", mul!, (B, A, A), (MB, MA, MA)),
           ("Matrix addition ", +, (A, A), (SA, SA)),
           ("Matrix addition (mutating) ", add!, (B, A, A), (MB, MA, MA)),
           ("Matrix determinant ", det, (A,), (SA,)),
           ("Matrix inverse ", inv, (A,), (SA,)),
           ("Matrix symmetric eigendecomposition", eigen, (A,), (SA,)),
           ("Matrix Cholesky decomposition ", cholesky, (A,), (SA,)),
           ("Matrix LU decomposition ", lu, (A,), (SA,)),
           ("Matrix QR decomposition ", qr, (A,), (SA,)),
    ]
    for (name, op, Aargs, SAargs) in ops
        # We load from Ref's here to avoid the compiler completely removing the
        # benchmark in some cases.
        #
        # Like any microbenchmark, the speedups you see here should only be
        # taken as roughly indicative of the speedup you may see in real code.
        if length(Aargs) == 1
            A1 = Ref(Aargs[1])
            SA1 = Ref(SAargs[1])
            speedup = @belapsed($op($A1[])) / @belapsed($op($SA1[]))
        elseif length(Aargs) == 2
            A1 = Ref(Aargs[1])
            A2 = Ref(Aargs[2])
            SA1 = Ref(SAargs[1])
            SA2 = Ref(SAargs[2])
            speedup = @belapsed($op($A1[], $A2[])) / @belapsed($op($SA1[], $SA2[]))
        elseif length(Aargs) == 3
            A1 = Ref(Aargs[1])
            A2 = Ref(Aargs[2])
            A3 = Ref(Aargs[3])
            SA1 = Ref(SAargs[1])
            SA2 = Ref(SAargs[2])
            SA3 = Ref(SAargs[3])
            speedup = @belapsed($op($A1[], $A2[], $A3[])) / @belapsed($op($SA1[], $SA2[], $SA3[]))
        else
        end
        println(name*" -> $(round(speedup, digits=1))x speedup")
    end
end

simple_bench(3)

```

---

<div class="post-metadata">

**Author:** ![chiion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chiion/32/37002_2.png) [@chiion](https://discourse.julialang.org/u/chiion)\
**Post date:** [December 8, 2023, 2:59am UTC](https://discourse.julialang.org/t/function-name-like-smatrix-n-n/107309/2 "2023-12-08T02:59:32Z")

</div>

`SMatrix{N,N}(...)` here is [parametric constuctor](https://docs.julialang.org/en/v1/manual/constructors/#Parametric-Constructors) to create a `SMatrix` object.  
As far as I know, I don’t think you can use curly brackets in normal function.
