# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=861

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 862

---

## [Speed-up JuMP model storing objects as Indexed tables](https://discourse.julialang.org/t/speed-up-jump-model-storing-objects-as-indexed-tables/24760)

<div class="topic-metadata">

**Author:** [@lgo](https://discourse.julialang.org/u/lgo)\
**Replies:** 5\
**Last updated:** [May 31, 2019, 11:02am UTC](https://discourse.julialang.org/t/speed-up-jump-model-storing-objects-as-indexed-tables/24760 "2019-05-31T11:02:59Z")

</div>

Hello, I’m new to Jula/JuMP and working on a very large optimization model, which generation I aim to fully automatize based on sets, relations among sets and parameters provided externally. I developed a basic procedur…

---

## [How to get the key with the maximum priority in a priority queue using Julia](https://discourse.julialang.org/t/how-to-get-the-key-with-the-maximum-priority-in-a-priority-queue-using-julia/24764)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 7\
**Last updated:** [May 30, 2019, 5:25pm UTC](https://discourse.julialang.org/t/how-to-get-the-key-with-the-maximum-priority-in-a-priority-queue-using-julia/24764 "2019-05-30T17:25:16Z")

</div>

I checked the following link https://juliacollections.github.io/DataStructures.jl/latest/priority-queue.html and did not find any related information. I guess one can use some trick with Base.Order.ForwardOrdering to acc…

---

## [Error problem when installing some packages in Julia](https://discourse.julialang.org/t/error-problem-when-installing-some-packages-in-julia/24658)

<div class="topic-metadata">

**Author:** [@GERSON\_EZEQUIEL\_HERN](https://discourse.julialang.org/u/GERSON_EZEQUIEL_HERN)\
**Replies:** 7\
**Last updated:** [May 30, 2019, 4:28pm UTC](https://discourse.julialang.org/t/error-problem-when-installing-some-packages-in-julia/24658 "2019-05-30T16:28:51Z")

</div>

I’m trying to install some packages in Julia. But at the time of installation I see this error. ERROR: The following package names could not be resolved: ImageTracking (not found in project, manifest or registry) Ple…

---

## [Inlining a function in a struct field](https://discourse.julialang.org/t/inlining-a-function-in-a-struct-field/24720)

<div class="topic-metadata">

**Author:** [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Replies:** 16\
**Last updated:** [May 30, 2019, 3:00pm UTC](https://discourse.julialang.org/t/inlining-a-function-in-a-struct-field/24720 "2019-05-30T15:00:15Z")

</div>

Hi, I have a question about inlining functions that hopefully somebody here can help me solve. I define an inlined potential function as follows @inline function V(x) 1.0/x^5 end; and also a user-defined type that…

---

## [Switching out the underlying array in a SubArray](https://discourse.julialang.org/t/switching-out-the-underlying-array-in-a-subarray/24727)

<div class="topic-metadata">

**Author:** [@FHell](https://discourse.julialang.org/u/FHell)\
**Replies:** 19\
**Last updated:** [May 30, 2019, 8:43am UTC](https://discourse.julialang.org/t/switching-out-the-underlying-array-in-a-subarray/24727 "2019-05-30T08:43:30Z")

</div>

Hi everyone, I am developing a package for simulating (possibly very heterogeneous) dynamical systems that live on networks: It’s very early days but usable, we just pushed v0.1. The core of this package is a loop ov…

---

## [\]dev a standard library package](https://discourse.julialang.org/t/dev-a-standard-library-package/24752)

<div class="topic-metadata">

**Author:** [@gasagna](https://discourse.julialang.org/u/gasagna)\
**Replies:** 3\
**Last updated:** [May 30, 2019, 7:56am UTC](https://discourse.julialang.org/t/dev-a-standard-library-package/24752 "2019-05-30T07:56:38Z")

</div>

I want to make some changes to my local install of SuiteSparse.jl and in the REPL I do \]dev SuiteSparse This create an image of the source code in ~/julia/dev/SuiteSparse that I can play with. However, importing the m…

---

## [Parametric subtyping, StackOverflowError issues](https://discourse.julialang.org/t/parametric-subtyping-stackoverflowerror-issues/24750)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 2\
**Last updated:** [May 29, 2019, 10:12pm UTC](https://discourse.julialang.org/t/parametric-subtyping-stackoverflowerror-issues/24750 "2019-05-29T22:12:36Z")

</div>

I think I don’t do it right, although it works (more or less)… Given a using StaticArrays struct Position{T} \<: FieldVector{3, T} x::T y::T z::T end I can create and calculate nicely with the type: \> Posi…

---

## [Block diagonal matrices](https://discourse.julialang.org/t/block-diagonal-matrices/24587)

<div class="topic-metadata">

**Author:** [@cgeoga](https://discourse.julialang.org/u/cgeoga)\
**Replies:** 8\
**Last updated:** [May 29, 2019, 9:36pm UTC](https://discourse.julialang.org/t/block-diagonal-matrices/24587 "2019-05-29T21:36:35Z")

</div>

Apologies if this has been discussed somewhere and I missed it in my searches, but I’m a bit confused by the behavior implemented for block diagonal matrices. For example, I note that if I did something like using Line…

---

## [DynamicHMC: Reached maximum number of iterations](https://discourse.julialang.org/t/dynamichmc-reached-maximum-number-of-iterations/24721)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 9\
**Last updated:** [May 29, 2019, 6:34pm UTC](https://discourse.julialang.org/t/dynamichmc-reached-maximum-number-of-iterations/24721 "2019-05-29T18:34:32Z")

</div>

This is likely a question for Tamas. @goedman and I have encountered an error the following error with DynamicHMC: ERROR: Reached maximum number of iterations while bisecting interval for ϵ. The error occurs intermittent…

---

## [Where is \`eigs()\` in Julia 1.0 version?](https://discourse.julialang.org/t/where-is-eigs-in-julia-1-0-version/24743)

<div class="topic-metadata">

**Author:** [@Carol](https://discourse.julialang.org/u/Carol)\
**Replies:** 7\
**Last updated:** [May 29, 2019, 6:19pm UTC](https://discourse.julialang.org/t/where-is-eigs-in-julia-1-0-version/24743 "2019-05-29T18:19:31Z")

</div>

Hi, I want to use eigs() to get the largest eigenvalue of a huge dense symmetric matrix.(50k by 50k) I can find eigs() in the documentation of Julia 0.6.4, but cannot find it in Julia 1.0.4 or 1.0.1. Could you please …

---

## [Broadcasting and pairs using \`.=\>\`](https://discourse.julialang.org/t/broadcasting-and-pairs-using/24739)

<div class="topic-metadata">

**Author:** [@j\_verzani](https://discourse.julialang.org/u/j_verzani)\
**Replies:** 3\
**Last updated:** [May 29, 2019, 4:06pm UTC](https://discourse.julialang.org/t/broadcasting-and-pairs-using/24739 "2019-05-29T16:06:08Z")

</div>

In replace a pair is used to specify a pattern and its replacement, as in replace("123", "2" =\> "two"). When broadcasting, the following won’t work (as expected) as a pair is iterable: replace.(\["123", "246"\], "2"=\>"two"…

---

## [How to debug a non-deterministic StackOverflowError?](https://discourse.julialang.org/t/how-to-debug-a-non-deterministic-stackoverflowerror/24718)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 15\
**Last updated:** [May 29, 2019, 2:09pm UTC](https://discourse.julialang.org/t/how-to-debug-a-non-deterministic-stackoverflowerror/24718 "2019-05-29T14:09:42Z")

</div>

I’m trying to implement the Rhea C++ constraint solving algorithm in Julia as a learning project. I’m simply translating the original source as far as I’m able into something that makes sense in Julia. I have implemente…

---

## [Wher variable "j" is declared as local?](https://discourse.julialang.org/t/wher-variable-j-is-declared-as-local/24734)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 3\
**Last updated:** [May 29, 2019, 1:56pm UTC](https://discourse.julialang.org/t/wher-variable-j-is-declared-as-local/24734 "2019-05-29T13:56:01Z")

</div>

julia\> function my\_fu() global j println(j) end my\_fu (generic function with 1 method) julia\> for j=1:3 global j my\_fu() end ERROR: syntax: variable "j" decla…

---

## [IF...ELSEIF...ELSE performance](https://discourse.julialang.org/t/if-elseif-else-performance/24622)

<div class="topic-metadata">

**Author:** [@drmartinrohde](https://discourse.julialang.org/u/drmartinrohde)\
**Replies:** 16\
**Last updated:** [May 29, 2019, 1:47pm UTC](https://discourse.julialang.org/t/if-elseif-else-performance/24622 "2019-05-29T13:47:06Z")

</div>

I need to use an IF…ELSEIF…ELSE statement in a large loop and I therefore did the following test to find the fastest implementation. In the following code a random number between 0 and 5 is chosen. Based on this outcome,…

---

## [Iterators.Repeated and Iterators.Take are not AbstractArrays](https://discourse.julialang.org/t/iterators-repeated-and-iterators-take-are-not-abstractarrays/24696)

<div class="topic-metadata">

**Author:** [@jonas-schulze](https://discourse.julialang.org/u/jonas-schulze)\
**Replies:** 4\
**Last updated:** [May 29, 2019, 11:29am UTC](https://discourse.julialang.org/t/iterators-repeated-and-iterators-take-are-not-abstractarrays/24696 "2019-05-29T11:29:19Z")

</div>

I tried to create a bidiagonal matrix using iterators: using .Iterators Bidiagonal(repeated(13, 37), repeated(42), :L) which doesn’t work: ERROR: MethodError: no method matching Bidiagonal(::Base.Iterators.Take{Base.I…

---

## [Cassette: compiler pass to translate branch to function](https://discourse.julialang.org/t/cassette-compiler-pass-to-translate-branch-to-function/24722)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 0\
**Last updated:** [May 29, 2019, 10:17am UTC](https://discourse.julialang.org/t/cassette-compiler-pass-to-translate-branch-to-function/24722 "2019-05-29T10:17:40Z")

</div>

I would like to use Cassette.jl to implement a compiler pass. The task is to (conditioned on types) translate code that contains a branch into a map over a function that contains the branch. An example of the transformat…

---

## [A priority queue with a vector of priorities](https://discourse.julialang.org/t/a-priority-queue-with-a-vector-of-priorities/24719)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 1\
**Last updated:** [May 29, 2019, 8:45am UTC](https://discourse.julialang.org/t/a-priority-queue-with-a-vector-of-priorities/24719 "2019-05-29T08:45:33Z")

</div>

This is fairly straightforward. I need to create a structure with keys and priorities. Then, priority queue would be a good candidate. For my understanding, each pair in the default priority queue of Julia has only one k…

---

## [Macro - parse argument type from input string](https://discourse.julialang.org/t/macro-parse-argument-type-from-input-string/24717)

<div class="topic-metadata">

**Author:** [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Replies:** 5\
**Last updated:** [May 29, 2019, 8:21am UTC](https://discourse.julialang.org/t/macro-parse-argument-type-from-input-string/24717 "2019-05-29T08:21:34Z")

</div>

I am trying to define this function (with “Int” as a string argument) through a macro function my\_function\_name(x::Int) return x\*x+one(x) end Here is my best try (which fails). I realize this MWE is not meaningful…

---

## [Optimizing Multidimensional Discrete Trapezoidal Integral](https://discourse.julialang.org/t/optimizing-multidimensional-discrete-trapezoidal-integral/24598)

<div class="topic-metadata">

**Author:** [@francesco.alemanno](https://discourse.julialang.org/u/francesco.alemanno)\
**Replies:** 12\
**Last updated:** [May 28, 2019, 9:45am UTC](https://discourse.julialang.org/t/optimizing-multidimensional-discrete-trapezoidal-integral/24598 "2019-05-28T09:45:00Z")

</div>

Update: Turned the fastest code in this thread in a small self contained package, in case someone needs it. Original Content of the post using BenchmarkTools @fastmath function trapz(x::T1, y::T2) where {fT,T1\<:Abstra…

---

## [Make the work of GC visible?](https://discourse.julialang.org/t/make-the-work-of-gc-visible/24642)

<div class="topic-metadata">

**Author:** [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Replies:** 1\
**Last updated:** [May 28, 2019, 7:49pm UTC](https://discourse.julialang.org/t/make-the-work-of-gc-visible/24642 "2019-05-28T19:49:11Z")

</div>

Is there are recommended way to make the work of GC visible? Like a command line option or compile time option? (or putting breakpoints in /bin/julia and run in gdb …). I’m (still) hunting a sig11 bug in (my) code and t…

---

## [Generate Random Symmetric Matrices with pmap](https://discourse.julialang.org/t/generate-random-symmetric-matrices-with-pmap/24706)

<div class="topic-metadata">

**Author:** [@VincentTam](https://discourse.julialang.org/u/VincentTam)\
**Replies:** 2\
**Last updated:** [May 28, 2019, 7:39pm UTC](https://discourse.julialang.org/t/generate-random-symmetric-matrices-with-pmap/24706 "2019-05-28T19:39:02Z")

</div>

I would like to call Symmetric() inside an @everywhere function, and use pmap to generate an array of Symmetric matrices, which are half of the sizeof normal ones, but I received an UndefVarError. using LinearAlgebra, D…

---

## [No ldiv!(x, A, b) on Bidiagonal matrices](https://discourse.julialang.org/t/no-ldiv-x-a-b-on-bidiagonal-matrices/24704)

<div class="topic-metadata">

**Author:** [@jonas-schulze](https://discourse.julialang.org/u/jonas-schulze)\
**Replies:** 0\
**Last updated:** [May 28, 2019, 6:59pm UTC](https://discourse.julialang.org/t/no-ldiv-x-a-b-on-bidiagonal-matrices/24704 "2019-05-28T18:59:40Z")

</div>

Suppose using LinearAlgebra n = 10 A = Bidiagonal(rand(n,n), :L) F = factorize(A) b = rand(n) x = similar(b) Then F === A and ldiv!(x, F, b) throws a no-method-error while ldiv!(F, b) is fine. Is this intended?

---

## [How to use multithread in IJulia](https://discourse.julialang.org/t/how-to-use-multithread-in-ijulia/24703)

<div class="topic-metadata">

**Author:** [@VincentTam](https://discourse.julialang.org/u/VincentTam)\
**Replies:** 2\
**Last updated:** [May 28, 2019, 6:16pm UTC](https://discourse.julialang.org/t/how-to-use-multithread-in-ijulia/24703 "2019-05-28T18:16:32Z")

</div>

I tried running julia -p2, using IJulia and notebook(), then in my notebook, I ran nprocs(), but it says the function is undefined.

---

## [Fun with Flux and Differential equations?](https://discourse.julialang.org/t/fun-with-flux-and-differential-equations/24676)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 12\
**Last updated:** [May 28, 2019, 4:04pm UTC](https://discourse.julialang.org/t/fun-with-flux-and-differential-equations/24676 "2019-05-28T16:04:15Z")

</div>

I’m playing around with machine learning (Flux) for dynamic systems. To make things concrete and simple, I have invented a scalar system: \\frac{dy}{dt} = 2(4-y)-10^2\\exp(-1/u)y^2 + 10^3\\exp(-1/u)y which could represen…

---

## [Using \`length\` makes the function type unstable](https://discourse.julialang.org/t/using-length-makes-the-function-type-unstable/22165)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 18\
**Last updated:** [May 28, 2019, 2:20pm UTC](https://discourse.julialang.org/t/using-length-makes-the-function-type-unstable/22165 "2019-05-28T14:20:21Z")

</div>

function countries() a = JSON.parsefile("country\_data.json", dicttype=Dict, use\_mmap=true) c = Vector{String}(undef, length(a)) for (i, d) in enumerate(a) c\[i\] = string(d\["name"\]) end return …

---

## [Openssl library missing with linux mint](https://discourse.julialang.org/t/openssl-library-missing-with-linux-mint/24679)

<div class="topic-metadata">

**Author:** [@Saer\_Samanipour](https://discourse.julialang.org/u/Saer_Samanipour)\
**Replies:** 1\
**Last updated:** [May 28, 2019, 1:14pm UTC](https://discourse.julialang.org/t/openssl-library-missing-with-linux-mint/24679 "2019-05-28T13:14:01Z")

</div>

Hi, I have recently moved my julia codes from a Windows machine to a linux mint one and getting the below error when trying to use a module that I wrote. “error compiling import\_files: error compiling cdf\_Import: error…

---

## [Zero-cost way to check if \`NamedTuple\` has a field?](https://discourse.julialang.org/t/zero-cost-way-to-check-if-namedtuple-has-a-field/24684)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 6\
**Last updated:** [May 28, 2019, 12:25pm UTC](https://discourse.julialang.org/t/zero-cost-way-to-check-if-namedtuple-has-a-field/24684 "2019-05-28T12:25:10Z")

</div>

Is there a way to check if a NamedTuple has a field :a that is elided by the compiler? For example, let t=(a=1, b=2). Then the fact that t has fields :a,:b is known at compile time (because this info is in the type of t)…

---

## [How to speed up this simple code? Multithreading, simd, inbounds](https://discourse.julialang.org/t/how-to-speed-up-this-simple-code-multithreading-simd-inbounds/19681)

<div class="topic-metadata">

**Author:** [@Juan](https://discourse.julialang.org/u/Juan)\
**Replies:** 39\
**Last updated:** [January 29, 2019, 8:22pm UTC](https://discourse.julialang.org/t/how-to-speed-up-this-simple-code-multithreading-simd-inbounds/19681 "2019-01-29T20:22:20Z")

</div>

I’m starting to use Julia and comparing its speed to R. For this simple example their speeds are almost the same. How would you make it faster? function f2(N) S = 0 Threads.@threads for i in 1:N se = 1:i …

---

## [Repeated serialization for distributed simulation](https://discourse.julialang.org/t/repeated-serialization-for-distributed-simulation/24672)

<div class="topic-metadata">

**Author:** [@nsna](https://discourse.julialang.org/u/nsna)\
**Replies:** 0\
**Last updated:** [May 28, 2019, 2:41am UTC](https://discourse.julialang.org/t/repeated-serialization-for-distributed-simulation/24672 "2019-05-28T02:41:38Z")

</div>

I’m trying to maximize a likelihood function that involves a large number of simulations of a reasonably complex model. Serialization time is a bottleneck. Does anything jump out as being a problem? Here is an example t…

---

## [Using @async and/or Channels to handle incoming data and process it](https://discourse.julialang.org/t/using-async-and-or-channels-to-handle-incoming-data-and-process-it/24669)

<div class="topic-metadata">

**Author:** [@pyrex41](https://discourse.julialang.org/u/pyrex41)\
**Replies:** 0\
**Last updated:** [May 28, 2019, 1:59am UTC](https://discourse.julialang.org/t/using-async-and-or-channels-to-handle-incoming-data-and-process-it/24669 "2019-05-28T01:59:01Z")

</div>

I am trying to implement what i think is a pretty standard use case for using Tasks / CoRoutines, but I am struggling to adapt the examples in the docs to my specific use case. Here’s an outline of what I want to do: #…

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=860)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=862)
