# How to use function inside a package

**URL:** <https://discourse.julialang.org/t/how-to-use-function-inside-a-package/49214>\
**Category:** General Usage\
**Created:** [October 29, 2020, 2:04am UTC](https://discourse.julialang.org/t/how-to-use-function-inside-a-package/49214 "2020-10-29T02:04:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nova](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@Nova](https://discourse.julialang.org/u/Nova)\
**Post date:** [October 29, 2020, 2:04am UTC](https://discourse.julialang.org/t/how-to-use-function-inside-a-package/49214/1 "2020-10-29T02:04:29Z")

</div>

I would like to use some of the functions included in the following package:  
[https://github.com/danspielman/Laplacians.jl/tree/master/src](https://github.com/danspielman/Laplacians.jl/tree/master/src)

For example the first file is IJV.jl .  
My question is how I am supposed to use these functions?  
I add the package by running pkg\> add Laplacians#master as it is said in the instructions. I assume that after adding the package, all the functions would be available and I can call them, is it right?  
For instance, if I want to use IJV.jl function, should I copy paste the code into my own file or I can just call the function?

---

<div class="post-metadata">

**Author:** ![Manu\_Francis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manu_francis/32/10010_2.png) [@Manu\_Francis](https://discourse.julialang.org/u/Manu_Francis)\
**Post date:** [October 29, 2020, 2:32am UTC](https://discourse.julialang.org/t/how-to-use-function-inside-a-package/49214/2 "2020-10-29T02:32:40Z")

</div>

@Nova: IJV.jl is a file in that package contains many functions.

You can access function name IJV in this file like below:

```julia
using Laplacians
ijv = IJV(A::SparseMatrixCSC)

```

---

<div class="post-metadata">

**Author:** ![Nova](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@Nova](https://discourse.julialang.org/u/Nova)\
**Post date:** [October 29, 2020, 2:40am UTC](https://discourse.julialang.org/t/how-to-use-function-inside-a-package/49214/3 "2020-10-29T02:40:53Z")

</div>

> [@Manu\_Francis](#):
>
> `using Laplacians`

This is what I get running: ijv = IJV(A), where A is a sparse matrix  
ERROR: UndefVarError: IJV not defined

---

<div class="post-metadata">

**Author:** ![timquelch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timquelch/32/18278_2.png) [@timquelch](https://discourse.julialang.org/u/timquelch)\
**Post date:** [October 29, 2020, 3:01am UTC](https://discourse.julialang.org/t/how-to-use-function-inside-a-package/49214/4 "2020-10-29T03:01:07Z")

</div>

```julia-repl
julia> using Laplacians

julia> :IJV in names(Laplacians)
false

julia> :IJV in names(Laplacians, all=true)
true

julia> Laplacians.IJV
Laplacians.IJV

help?> Laplacians.IJV
  ijv = IJV(A::SparseMatrixCSC)

  Convert a sparse matrix to an IJV.

```

You can use it like `Laplacians.IJV(A)`. This is because `IJV` is not exported by Laplacians

edit: I had a look at the docs, and this is intended. `IJV` is listed under “unexported (private) functions” in the API reference [here](https://danspielman.github.io/Laplacians.jl/latest/privateFuncs/#Laplacians.IJV-Union%7BTuple%7BSparseArrays.SparseMatrixCSC%7BTv,Ti%7D%7D,%20Tuple%7BTi%7D,%20Tuple%7BTv%7D%7D%20where%20Ti%20where%20Tv)
