# General Usage

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

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

**Page:** 388

---

## [How to efficiently determine if a column of a matrix is made of integers](https://discourse.julialang.org/t/how-to-efficiently-determine-if-a-column-of-a-matrix-is-made-of-integers/88217)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 6\
**Last updated:** [October 4, 2022, 5:18pm UTC](https://discourse.julialang.org/t/how-to-efficiently-determine-if-a-column-of-a-matrix-is-made-of-integers/88217 "2022-10-04T17:18:41Z")

</div>

Which is the most efficient way to determine if the columns of a matrix are all integers, e.g. a = \[1 1.5 2; 10 3.1 3\] columns 1 and 3 ? Note that if I would have defined a = Any\[1 1.5 2; 10 3.1 3\] I could have used j…

---

## [Potential performance regressions in Julia 1.8 for special un-precompiled type dispatches and how to fix them](https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359)

<div class="topic-metadata">

**Author:** [@sloede](https://discourse.julialang.org/u/sloede)\
**Replies:** 25\
**Last updated:** [October 4, 2022, 4:02pm UTC](https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359 "2022-10-04T16:02:53Z")

</div>

TL;DR With Julia 1.8.0 (as opposed to Julia 1.7.3), for OrdinaryDiffEq v6.24.0 and Trixi.jl v0.4.44, we observe that package installation time increased by 20-50% package loading time increased by 30-50% compilation ti…

---

## [Could not load symbol with ccall](https://discourse.julialang.org/t/could-not-load-symbol-with-ccall/88231)

<div class="topic-metadata">

**Author:** [@ovt](https://discourse.julialang.org/u/ovt)\
**Replies:** 2\
**Last updated:** [October 4, 2022, 2:02pm UTC](https://discourse.julialang.org/t/could-not-load-symbol-with-ccall/88231 "2022-10-04T14:02:24Z")

</div>

I’m trying to call this function #include \<stdlib.h\> #include \<stdio.h\> #include \<time.h\> #include \<math.h\> #include \<string.h\> #define datatype double /\* type of the elements in y \*/ static void simplexproj\_Condat(da…

---

## [How to extract sub-matrices (or their indexes) of Block Diagonal Matrix?](https://discourse.julialang.org/t/how-to-extract-sub-matrices-or-their-indexes-of-block-diagonal-matrix/88188)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 5\
**Last updated:** [October 4, 2022, 1:17pm UTC](https://discourse.julialang.org/t/how-to-extract-sub-matrices-or-their-indexes-of-block-diagonal-matrix/88188 "2022-10-04T13:17:53Z")

</div>

Is there a function in Julia to return(extract) the sub-matrices (or their indexes) from Block Diagonal Matrix similar to here Extract matrices from a Block Diagonal Matrix?? For example, I need to return A\[1:3,1:3\], A\[…

---

## [How do you make an arbitrarily nested for loop?](https://discourse.julialang.org/t/how-do-you-make-an-arbitrarily-nested-for-loop/88225)

<div class="topic-metadata">

**Author:** [@AwesomeQuest](https://discourse.julialang.org/u/AwesomeQuest)\
**Replies:** 2\
**Last updated:** [October 4, 2022, 12:39pm UTC](https://discourse.julialang.org/t/how-do-you-make-an-arbitrarily-nested-for-loop/88225 "2022-10-04T12:39:10Z")

</div>

Say you have an array of ranges rngs = \[10:-1:0, 10:-4:2, 10:-3:1\]. How would you make a nested loop equivalent to inds = zeros(length(rngs)) for inds\[1\] in rngs\[1\], inds\[2\] in rngs\[2\], inds\[3\] in rngs\[3\] But for an a…

---

## [\[Translating\] from Pascal to Julia](https://discourse.julialang.org/t/translating-from-pascal-to-julia/88184)

<div class="topic-metadata">

**Author:** [@fabbius69](https://discourse.julialang.org/u/fabbius69)\
**Replies:** 24\
**Last updated:** [October 4, 2022, 11:34am UTC](https://discourse.julialang.org/t/translating-from-pascal-to-julia/88184 "2022-10-04T11:34:06Z")

</div>

is it possible to have similar code in julia? thanks “type lo=array\[1…5,1…10\]of smallint; nom=string\[25\]; lot=record num:lo; ind:smallint; anno:smallint; mese:string\[15\]; end; fi=file of lot; var f2,f3:fi;”

---

## [Too many allocations for this couple of small functions](https://discourse.julialang.org/t/too-many-allocations-for-this-couple-of-small-functions/88170)

<div class="topic-metadata">

**Author:** [@daviddoij](https://discourse.julialang.org/u/daviddoij)\
**Replies:** 4\
**Last updated:** [October 4, 2022, 9:00am UTC](https://discourse.julialang.org/t/too-many-allocations-for-this-couple-of-small-functions/88170 "2022-10-04T09:00:49Z")

</div>

Hi there, newbie here solved Project Euler #4 problem with Julia and, althogh the timing is good, I got too many allocations (around 100k) for such a small program. I’ve tried with explicit types in the variables and d…

---

## [On arrays with inline elements (vs pointer indirection)](https://discourse.julialang.org/t/on-arrays-with-inline-elements-vs-pointer-indirection/88211)

<div class="topic-metadata">

**Author:** [@torrance](https://discourse.julialang.org/u/torrance)\
**Replies:** 6\
**Last updated:** [October 4, 2022, 8:03am UTC](https://discourse.julialang.org/t/on-arrays-with-inline-elements-vs-pointer-indirection/88211 "2022-10-04T08:03:48Z")

</div>

I was answering another question here and realised how shaky my knowledge of Julia array storage is, regarding inline storage. Somewhere (?) I read that if your struct is isbits and immutable, it can be stored directly …

---

## [Unable to run an example code using DataStructures.jl](https://discourse.julialang.org/t/unable-to-run-an-example-code-using-datastructures-jl/88204)

<div class="topic-metadata">

**Author:** [@Alejandro\_Quiaro\_San](https://discourse.julialang.org/u/Alejandro_Quiaro_San)\
**Replies:** 1\
**Last updated:** [October 4, 2022, 7:54am UTC](https://discourse.julialang.org/t/unable-to-run-an-example-code-using-datastructures-jl/88204 "2022-10-04T07:54:27Z")

</div>

I am trying to run a simple example code from the DataStructures.jl package but I get an error. data = collect(enumerate(\["foo", "bar", "baz"\])) h1 = BinaryHeap(data) # Standard lexicographic ordering for tuples first(…

---

## [Vectors with elements of same type but different parametric type](https://discourse.julialang.org/t/vectors-with-elements-of-same-type-but-different-parametric-type/88190)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 5\
**Last updated:** [October 4, 2022, 7:19am UTC](https://discourse.julialang.org/t/vectors-with-elements-of-same-type-but-different-parametric-type/88190 "2022-10-04T07:19:20Z")

</div>

I need to work with a set of points that might each have a different type. Consider as a rough example: abstract type AbstractLabel end struct LabelA \<: AbstractLabel end struct LabelB \<: AbstractLabel end struct LabelC…

---

## [Fail to call for Matlab 2022b through "MATLAB.jl"](https://discourse.julialang.org/t/fail-to-call-for-matlab-2022b-through-matlab-jl/88200)

<div class="topic-metadata">

**Author:** [@lionisxn](https://discourse.julialang.org/u/lionisxn)\
**Replies:** 0\
**Last updated:** [October 4, 2022, 2:07am UTC](https://discourse.julialang.org/t/fail-to-call-for-matlab-2022b-through-matlab-jl/88200 "2022-10-04T02:07:53Z")

</div>

I often call for matlab in Julia for some comparison purposes. Everything goes well in MATLAB 2021B. However, it crashed after I upgraded MATLAB to the new version of 2022b in Windows 11. I have rebuilt the package in Ju…

---

## [Optimising function for broadcast](https://discourse.julialang.org/t/optimising-function-for-broadcast/87918)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 9\
**Last updated:** [October 4, 2022, 4:25am UTC](https://discourse.julialang.org/t/optimising-function-for-broadcast/87918 "2022-10-04T04:25:29Z")

</div>

function f( a, b ) c = 2a b + c end f.( 1, 1:100 ) I believe c = 2a will be calculated 100 times (every iteration of the broadcast). Is there a way to have c evaluated once and cached ? without r…

---

## [When to use broadcasting with . vs map](https://discourse.julialang.org/t/when-to-use-broadcasting-with-vs-map/58078)

<div class="topic-metadata">

**Author:** [@SL6Trip](https://discourse.julialang.org/u/SL6Trip)\
**Replies:** 23\
**Last updated:** [October 4, 2022, 2:49am UTC](https://discourse.julialang.org/t/when-to-use-broadcasting-with-vs-map/58078 "2022-10-04T02:49:56Z")

</div>

If I want to apply a function across say a Vector in julia, there are two ways I could do it: map(f, seq) f.(seq) Is any way “better” than the other? In fact, is there any difference in the implementation between usin…

---

## [Mysterious allocation in function returning Union type](https://discourse.julialang.org/t/mysterious-allocation-in-function-returning-union-type/88189)

<div class="topic-metadata">

**Author:** [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Replies:** 3\
**Last updated:** [October 4, 2022, 1:48am UTC](https://discourse.julialang.org/t/mysterious-allocation-in-function-returning-union-type/88189 "2022-10-04T01:48:40Z")

</div>

I’m looking at functions with return type Union{T,Nothing} for some concrete type T. Most of the time they don’t allocate. But where does the allocation in f(a1, nothing) in the code below come from? Is there a way to av…

---

## [MutableBinaryHeap suddenly stopped working?](https://discourse.julialang.org/t/mutablebinaryheap-suddenly-stopped-working/88197)

<div class="topic-metadata">

**Author:** [@Alejandro\_Quiaro\_San](https://discourse.julialang.org/u/Alejandro_Quiaro_San)\
**Replies:** 0\
**Last updated:** [October 4, 2022, 12:33am UTC](https://discourse.julialang.org/t/mutablebinaryheap-suddenly-stopped-working/88197 "2022-10-04T00:33:29Z")

</div>

Hello, I have a function that is using a MutableBinaryHeap. The code was running fine, and suddenly it stopped working. It is giving the following error: ERROR: MethodError: no method matching MutableBinaryHeap(::typeof…

---

## [Problem converting serial code to parallel code with FLoops](https://discourse.julialang.org/t/problem-converting-serial-code-to-parallel-code-with-floops/87610)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 9\
**Last updated:** [October 3, 2022, 9:52pm UTC](https://discourse.julialang.org/t/problem-converting-serial-code-to-parallel-code-with-floops/87610 "2022-10-03T21:52:55Z")

</div>

I have the following code which loops over some indices and adds values to two separate parts of an array. using FLoops, Random function update\_u!(du, u, k, q, j) v = \[k, (k + 1) % length(u) + 1, (k + 7) % length(u…

---

## [A problem about performance](https://discourse.julialang.org/t/a-problem-about-performance/88182)

<div class="topic-metadata">

**Author:** [@XuJingye2022](https://discourse.julialang.org/u/XuJingye2022)\
**Replies:** 30\
**Last updated:** [October 3, 2022, 8:40pm UTC](https://discourse.julialang.org/t/a-problem-about-performance/88182 "2022-10-03T20:40:15Z")

</div>

My version is 1.6.7, # global variable v = rand(10000) function fun1() s = 0.0 for i in v::Vector{Float64} s += i end end function fun2(x::Vector{Float64}) s = 0.0 for i in x s += i…

---

## [Fastest way to calculate a rasterised Voronoi diagram without a GPU](https://discourse.julialang.org/t/fastest-way-to-calculate-a-rasterised-voronoi-diagram-without-a-gpu/77016)

<div class="topic-metadata">

**Author:** [@jacobusmmsmit](https://discourse.julialang.org/u/jacobusmmsmit)\
**Replies:** 17\
**Last updated:** [October 3, 2022, 8:05pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-a-rasterised-voronoi-diagram-without-a-gpu/77016 "2022-10-03T20:05:39Z")

</div>

Context: Hi everyone, I’m using Turing.jl with NUTS, to infer the parameters a chaotic ODE system. Due to the chaos, doing inference on the positions of the particles as the time window of the inference gets longer beco…

---

## [Why Plots.spy directive does not show \`one values\`?](https://discourse.julialang.org/t/why-plots-spy-directive-does-not-show-one-values/88168)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 2\
**Last updated:** [October 3, 2022, 7:35pm UTC](https://discourse.julialang.org/t/why-plots-spy-directive-does-not-show-one-values/88168 "2022-10-03T19:35:22Z")

</div>

I am plotting the sparsity of matrix A by using Plots.spy, but the plot is not showing the ones values, e.g., A\[13,4\], A\[14,5\],A\[15,6\]. Can you guide me for the reason? Is there a way also to show the non-zero elements…

---

## [How to quickly identify nearby stations?](https://discourse.julialang.org/t/how-to-quickly-identify-nearby-stations/88124)

<div class="topic-metadata">

**Author:** [@Leon6](https://discourse.julialang.org/u/Leon6)\
**Replies:** 5\
**Last updated:** [October 3, 2022, 2:52pm UTC](https://discourse.julialang.org/t/how-to-quickly-identify-nearby-stations/88124 "2022-10-03T14:52:16Z")

</div>

I have a total of 1 million stations numbered from 1 to 1 million. For each of them, how do I quickly identify the rest of the stations (Station numbers) that are within 2 km of distance? Any tips would be greatly appre…

---

## [How to retrive input values from Flux Dense layer](https://discourse.julialang.org/t/how-to-retrive-input-values-from-flux-dense-layer/88142)

<div class="topic-metadata">

**Author:** [@Molox](https://discourse.julialang.org/u/Molox)\
**Replies:** 2\
**Last updated:** [October 3, 2022, 5:34pm UTC](https://discourse.julialang.org/t/how-to-retrive-input-values-from-flux-dense-layer/88142 "2022-10-03T17:34:40Z")

</div>

Hi, I was loading many Flux models (bson file) and had no idea about the layer information. I am able to find the activation function by calling the field “σ”. I searched around but just could not find the field name t…

---

## [JuliaCall: is it possible to pass objects from Python to Julia Main?](https://discourse.julialang.org/t/juliacall-is-it-possible-to-pass-objects-from-python-to-julia-main/88156)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 2\
**Last updated:** [October 3, 2022, 4:11pm UTC](https://discourse.julialang.org/t/juliacall-is-it-possible-to-pass-objects-from-python-to-julia-main/88156 "2022-10-03T16:11:52Z")

</div>

Using JuliaCall, is it possible to pass objects from Python to Julia so that I can then use them in evaluated Julia code ? E.g.: \>\>\> from juliacall import Main as jl \>\>\> xpy = \[1,2,3\] \>\>\> jl.xj = xpy # AttributeError: …

---

## [How to list parametric type instances(?](https://discourse.julialang.org/t/how-to-list-parametric-type-instances/88165)

<div class="topic-metadata">

**Author:** [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Replies:** 0\
**Last updated:** [October 3, 2022, 4:11pm UTC](https://discourse.julialang.org/t/how-to-list-parametric-type-instances/88165 "2022-10-03T16:11:15Z")

</div>

I have a bit of code that can result in the recursive combination of types. Where the below mytype can be type with A & B being primitive types as well as mytype. Is there anyway to list out all the different variations…

---

## [Permissions denied to github actions bot while building documentation](https://discourse.julialang.org/t/permissions-denied-to-github-actions-bot-while-building-documentation/88158)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 1\
**Last updated:** [October 3, 2022, 3:10pm UTC](https://discourse.julialang.org/t/permissions-denied-to-github-actions-bot-while-building-documentation/88158 "2022-10-03T15:10:04Z")

</div>

The documentation for ApproxFun is not being built, and the build process fails with an error message remote: Permission to JuliaApproximation/ApproxFun.jl.git denied to github-actions\[bot\]. fatal: unable to access 'htt…

---

## [Sampling an index from a boolean array](https://discourse.julialang.org/t/sampling-an-index-from-a-boolean-array/87931)

<div class="topic-metadata">

**Author:** [@yuvalw](https://discourse.julialang.org/u/yuvalw)\
**Replies:** 7\
**Last updated:** [October 3, 2022, 11:15am UTC](https://discourse.julialang.org/t/sampling-an-index-from-a-boolean-array/87931 "2022-10-03T11:15:24Z")

</div>

Hello, I often need to sample an index from a boolean array. For example: julia\> A = rand(Bool,3,3) 3×3 Matrix{Bool}: 1 1 1 1 0 0 1 0 0 julia\> idx = rand(findall(A)) CartesianIndex(2, 1) Can I somehow sample …

---

## [Adding list of tuples](https://discourse.julialang.org/t/adding-list-of-tuples/88111)

<div class="topic-metadata">

**Author:** [@Phuntsho](https://discourse.julialang.org/u/Phuntsho)\
**Replies:** 11\
**Last updated:** [October 3, 2022, 7:29am UTC](https://discourse.julialang.org/t/adding-list-of-tuples/88111 "2022-10-03T07:29:56Z")

</div>

I have two long lists of tuples: For instance, A1 = \[(2,3),(4,5)…\] and A2 = \[(4,6),(2,8)…\]. The first element of each tuple is common to both lists. Now I want to produce a new list, A3, such that whenever the first elem…

---

## [Translate sum and long variables to Julia (VS Code)](https://discourse.julialang.org/t/translate-sum-and-long-variables-to-julia-vs-code/88145)

<div class="topic-metadata">

**Author:** [@tryjulia](https://discourse.julialang.org/u/tryjulia)\
**Replies:** 1\
**Last updated:** [October 3, 2022, 7:28am UTC](https://discourse.julialang.org/t/translate-sum-and-long-variables-to-julia-vs-code/88145 "2022-10-03T07:28:42Z")

</div>

Hi, I want to write code to transform the mathematical expression of: y=sum from k=0 to k=infinite of x^k/k! where x and y are long real var. I try to write the code such this: function taylor(k) k = (0:Inf) x = l…

---

## [Mergewith(dicts...)](https://discourse.julialang.org/t/mergewith-dicts/88136)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 7\
**Last updated:** [October 3, 2022, 4:44am UTC](https://discourse.julialang.org/t/mergewith-dicts/88136 "2022-10-03T04:44:34Z")

</div>

Why does this discard the first dict instead of merging? This signature is undocumented. julia\> mergewith(Dict(1=\>10), Dict(2=\>20)) Dict{Int64, Int64} with 1 entry: 2 =\> 20

---

## [Error in training Deep Equilibrium Models (DEQ)](https://discourse.julialang.org/t/error-in-training-deep-equilibrium-models-deq/87958)

<div class="topic-metadata">

**Author:** [@Molox](https://discourse.julialang.org/u/Molox)\
**Replies:** 4\
**Last updated:** [October 3, 2022, 4:04am UTC](https://discourse.julialang.org/t/error-in-training-deep-equilibrium-models-deq/87958 "2022-10-03T04:04:02Z")

</div>

I read the Blog about “Composability in Julia: Implementing Deep Equilibrium Models via Neural ODEs”. I tried to reproduce the code to train the MNIST dataset, but it returns an error during training: ERROR: MethodErro…

---

## [Why get 0 for 2^(3^4)?](https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114)

<div class="topic-metadata">

**Author:** [@pppoe5](https://discourse.julialang.org/u/pppoe5)\
**Replies:** 7\
**Last updated:** [October 3, 2022, 3:54am UTC](https://discourse.julialang.org/t/why-get-0-for-2-3-4/88114 "2022-10-03T03:54:49Z")

</div>

In Julia REPL, I input 2^(3^4) or big(2^(3^4)), still give me 0. So, how to get the right answer?

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

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