# General Usage

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

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

**Page:** 885

---

## [Organizing Threads and Block @cuda, 3D Arrays](https://discourse.julialang.org/t/organizing-threads-and-block-cuda-3d-arrays/21975)

<div class="topic-metadata">

**Author:** [@Noobie76](https://discourse.julialang.org/u/Noobie76)\
**Replies:** 2\
**Last updated:** [March 18, 2019, 9:00am UTC](https://discourse.julialang.org/t/organizing-threads-and-block-cuda-3d-arrays/21975 "2019-03-18T09:00:46Z")

</div>

Hi I have a question concerning the organization of threads and blocks calling a custom CUDA kernel. First of all my workstation runs a GTX Titan, here are the corresponding specs Device 0: "GeForce GTX TITAN" CUDA D…

---

## [Example for an AbstractToken from TextParse for a JuliaDB](https://discourse.julialang.org/t/example-for-an-abstracttoken-from-textparse-for-a-juliadb/20945)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 2\
**Last updated:** [March 18, 2019, 3:55am UTC](https://discourse.julialang.org/t/example-for-an-abstracttoken-from-textparse-for-a-juliadb/20945 "2019-03-18T03:55:54Z")

</div>

In JuliaDB’s documentation for loadtable, there is an explanation of how to use an AbstractToken object from TextParse in order to parse columns from a CSV file. Has anyone managed to do that? Say correctly parse number…

---

## [Frequent (and annoying) precompilation when using several Pkg environments](https://discourse.julialang.org/t/frequent-and-annoying-precompilation-when-using-several-pkg-environments/21963)

<div class="topic-metadata">

**Author:** [@fedxa](https://discourse.julialang.org/u/fedxa)\
**Replies:** 3\
**Last updated:** [March 17, 2019, 6:05pm UTC](https://discourse.julialang.org/t/frequent-and-annoying-precompilation-when-using-several-pkg-environments/21963 "2019-03-17T18:05:57Z")

</div>

There is currently a quite annoying precompilation behaviour. I have the following configuration. I have two working environments one for “Project” and a generic one. Both have, for example, DifferentialEquations inst…

---

## [Repeatable generation of (fake) UUIDs](https://discourse.julialang.org/t/repeatable-generation-of-fake-uuids/21960)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 6\
**Last updated:** [March 17, 2019, 1:53pm UTC](https://discourse.julialang.org/t/repeatable-generation-of-fake-uuids/21960 "2019-03-17T13:53:58Z")

</div>

I need to generate something that would look like a UUID (so that UUID(something) will not error), but depend on some input. So in the same way this works: rand(MersenneTwister(0)) == rand(MersenneTwister(0)) I want t…

---

## [Reusing buffer arrays by providing them as arguments to functions](https://discourse.julialang.org/t/reusing-buffer-arrays-by-providing-them-as-arguments-to-functions/21942)

<div class="topic-metadata">

**Author:** [@jonas-schulze](https://discourse.julialang.org/u/jonas-schulze)\
**Replies:** 5\
**Last updated:** [March 17, 2019, 9:43am UTC](https://discourse.julialang.org/t/reusing-buffer-arrays-by-providing-them-as-arguments-to-functions/21942 "2019-03-17T09:43:06Z")

</div>

I have a function that needs a Vector{Int} for buffering, which I would like to reuse when I call that function over and over again in a loop. My idea was to create that vector outside and clearing it before every use. I…

---

## [Sorting algorithms: partial quicksort usage](https://discourse.julialang.org/t/sorting-algorithms-partial-quicksort-usage/1007)

<div class="topic-metadata">

**Author:** [@jesse](https://discourse.julialang.org/u/jesse)\
**Replies:** 4\
**Last updated:** [March 16, 2019, 10:57pm UTC](https://discourse.julialang.org/t/sorting-algorithms-partial-quicksort-usage/1007 "2019-03-16T22:57:57Z")

</div>

Hi, Im trying to understand the partial quicksort algorithm. I expected it work so that if I specify alg=PartialQuickSort(3) the algorithm sorts so that indexes 1,2,3 contains the smallest elements and the rest (4,…,n) …

---

## [Most performant way to get 0-d array pointing to a variable](https://discourse.julialang.org/t/most-performant-way-to-get-0-d-array-pointing-to-a-variable/21947)

<div class="topic-metadata">

**Author:** [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Replies:** 2\
**Last updated:** [March 16, 2019, 8:50pm UTC](https://discourse.julialang.org/t/most-performant-way-to-get-0-d-array-pointing-to-a-variable/21947 "2019-03-16T20:50:46Z")

</div>

First this my be a little ill formatted as I am typing it on my phone at a muffler shop. I am Trying to figure out what the most performance way of generating a 0-dim array of a variable to use as passing by ref. Now f…

---

## [Can not install Optim package julia 1.0.2 jupyter](https://discourse.julialang.org/t/can-not-install-optim-package-julia-1-0-2-jupyter/21812)

<div class="topic-metadata">

**Author:** [@Santiago\_Cuervo](https://discourse.julialang.org/u/Santiago_Cuervo)\
**Replies:** 2\
**Last updated:** [March 16, 2019, 5:22pm UTC](https://discourse.julialang.org/t/can-not-install-optim-package-julia-1-0-2-jupyter/21812 "2019-03-16T17:22:07Z")

</div>

Ive not been able to install Optim Package in julia 1.0.2 using Jupyter. Is it not supported on that Julia version?

---

## [Issues installing a range of packages](https://discourse.julialang.org/t/issues-installing-a-range-of-packages/21894)

<div class="topic-metadata">

**Author:** [@nickeubank](https://discourse.julialang.org/u/nickeubank)\
**Replies:** 7\
**Last updated:** [March 16, 2019, 3:08pm UTC](https://discourse.julialang.org/t/issues-installing-a-range-of-packages/21894 "2019-03-16T15:08:25Z")

</div>

I’m having an awful time getting CodecZlib, ZMQ, and MbedTLS to install. All give me errors that look roughly like this: (v1.1) pkg\> build MbedTLS Building MbedTLS → \`~/.julia/packages/MbedTLS/X4xar/deps/build.log\` ┌ …

---

## [euler method with julia1.0](https://discourse.julialang.org/t/euler-method-with-julia1-0/20494)

<div class="topic-metadata">

**Author:** [@11111](https://discourse.julialang.org/u/11111)\
**Replies:** 4\
**Last updated:** [March 16, 2019, 2:37pm UTC](https://discourse.julialang.org/t/euler-method-with-julia1-0/20494 "2019-03-16T14:37:10Z")

</div>

Hi, i’m a beginner at julialang. I try to use euler method with julia1.0. But the following error occured. Could you tell me the code for the resolution solution?

---

## [Increading the number of threads of execution](https://discourse.julialang.org/t/increading-the-number-of-threads-of-execution/21925)

<div class="topic-metadata">

**Author:** [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)\
**Replies:** 9\
**Last updated:** [March 16, 2019, 7:58am UTC](https://discourse.julialang.org/t/increading-the-number-of-threads-of-execution/21925 "2019-03-16T07:58:20Z")

</div>

Hi, I am trying to learn multi-threaded programming on Julia, and I am trying to increase the number of threads to 4 (since my computer has 4 cores), by typing export JULIA\_NUM\_THREADS=4 on my terminal. I am on CentOs …

---

## [Trigger redisplay of the REPL prompt](https://discourse.julialang.org/t/trigger-redisplay-of-the-repl-prompt/21926)

<div class="topic-metadata">

**Author:** [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Replies:** 2\
**Last updated:** [March 15, 2019, 9:29pm UTC](https://discourse.julialang.org/t/trigger-redisplay-of-the-repl-prompt/21926 "2019-03-15T21:29:54Z")

</div>

I have an asynchronous event that triggers some output in the REPL, and I’d like to trigger a redisplay of the prompt afterwards, so that users know the REPL is still active. Is there something in the REPL std lib to do …

---

## [Base function in Cuda kernels](https://discourse.julialang.org/t/base-function-in-cuda-kernels/21866)

<div class="topic-metadata">

**Author:** [@Noobie76](https://discourse.julialang.org/u/Noobie76)\
**Replies:** 8\
**Last updated:** [March 15, 2019, 8:48pm UTC](https://discourse.julialang.org/t/base-function-in-cuda-kernels/21866 "2019-03-15T20:48:17Z")

</div>

Hi there, I hope this is not a duplicate. If so, please fill free to shit this post. I’m relatively new to Julia. I currently working on a numerical project which I want to implement on the GPU. Therefore I’m using the…

---

## [How can I make Flux use all my CPUs?](https://discourse.julialang.org/t/how-can-i-make-flux-use-all-my-cpus/21869)

<div class="topic-metadata">

**Author:** [@yao](https://discourse.julialang.org/u/yao)\
**Replies:** 10\
**Last updated:** [March 15, 2019, 7:58pm UTC](https://discourse.julialang.org/t/how-can-i-make-flux-use-all-my-cpus/21869 "2019-03-15T19:58:02Z")

</div>

Hi all, I already set export JULIA\_NUM\_THREADS=12 and in REPL I checked Threads.nthreads() =12. But when I ran the training, I only saw Julia(Flux) using 8 CPUs, and, they were not in full power. How can I make Flux us…

---

## [Documentation on for-loops and scoping (in and out of REPL)?](https://discourse.julialang.org/t/documentation-on-for-loops-and-scoping-in-and-out-of-repl/21922)

<div class="topic-metadata">

**Author:** [@nickeubank](https://discourse.julialang.org/u/nickeubank)\
**Replies:** 2\
**Last updated:** [March 15, 2019, 7:08pm UTC](https://discourse.julialang.org/t/documentation-on-for-loops-and-scoping-in-and-out-of-repl/21922 "2019-03-15T19:08:10Z")

</div>

So I can see that issues of scoping are a HUGE subject of debate in different places, and I don’t mean to join the debates over what julia should do. Rather, I was hoping someone could lay out what the current state is …

---

## [Is there a better way to do error handling on Julia than try/catch?](https://discourse.julialang.org/t/is-there-a-better-way-to-do-error-handling-on-julia-than-try-catch/21716)

<div class="topic-metadata">

**Author:** [@mrkaspa](https://discourse.julialang.org/u/mrkaspa)\
**Replies:** 19\
**Last updated:** [March 15, 2019, 3:17pm UTC](https://discourse.julialang.org/t/is-there-a-better-way-to-do-error-handling-on-julia-than-try-catch/21716 "2019-03-15T15:17:24Z")

</div>

Julia could make error types by using Union or maybe a la Golang with tuples, why does it choose to use the terrible approach that is to treat errors as exceptions?. To differentiate this brings better logic flow to the …

---

## [How to create an Array of some concrete type (i.e., not Any) with zero size?](https://discourse.julialang.org/t/how-to-create-an-array-of-some-concrete-type-i-e-not-any-with-zero-size/21898)

<div class="topic-metadata">

**Author:** [@Gu\_Junhua](https://discourse.julialang.org/u/Gu_Junhua)\
**Replies:** 2\
**Last updated:** [March 15, 2019, 11:58am UTC](https://discourse.julialang.org/t/how-to-create-an-array-of-some-concrete-type-i-e-not-any-with-zero-size/21898 "2019-03-15T11:58:37Z")

</div>

a=\[\] # you will get an Array{Any, 1} with zero size That’s not I want. a=fill(0::Int, 0) # yes you can get a zero sized Array{Int64, 1}. But fill as is suggested by its name should not be used to initialize an empty a…

---

## [Proper definition of eltype for custom iterator](https://discourse.julialang.org/t/proper-definition-of-eltype-for-custom-iterator/21903)

<div class="topic-metadata">

**Author:** [@timueh](https://discourse.julialang.org/u/timueh)\
**Replies:** 2\
**Last updated:** [March 15, 2019, 9:06am UTC](https://discourse.julialang.org/t/proper-definition-of-eltype-for-custom-iterator/21903 "2019-03-15T09:06:56Z")

</div>

I was looking at the Julia manual and read about custom iterators. The gist: having defined my own type, once I extend Base.iterate + Base.length + Base.eltype to work with my own type, I can do cool stuff. Here’s the e…

---

## [Running a function inside BenchmarkTools breaks it](https://discourse.julialang.org/t/running-a-function-inside-benchmarktools-breaks-it/21901)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 2\
**Last updated:** [March 15, 2019, 8:15am UTC](https://discourse.julialang.org/t/running-a-function-inside-benchmarktools-breaks-it/21901 "2019-03-15T08:15:30Z")

</div>

Running this function normally it stops, but calling it with @btime creates an infinite loop. What is going on here? using BenchmarkTools function myfun(aa) val = (((length(aa) \* 3) \>\> 2)\>\>3)\<\<3 while val \> 1…

---

## [Ccall to external app and have julia move on](https://discourse.julialang.org/t/ccall-to-external-app-and-have-julia-move-on/12800)

<div class="topic-metadata">

**Author:** [@archimedes4000](https://discourse.julialang.org/u/archimedes4000)\
**Replies:** 3\
**Last updated:** [March 15, 2019, 4:18am UTC](https://discourse.julialang.org/t/ccall-to-external-app-and-have-julia-move-on/12800 "2019-03-15T04:18:46Z")

</div>

I have a visualization application that is in C++ and julia is providing the data. I want to be able to invoke the visualization application and have julia call it and then move on. Right now, the visualization applica…

---

## [Multi-threading or multi-processing with iterators](https://discourse.julialang.org/t/multi-threading-or-multi-processing-with-iterators/21834)

<div class="topic-metadata">

**Author:** [@fnin](https://discourse.julialang.org/u/fnin)\
**Replies:** 3\
**Last updated:** [March 14, 2019, 9:10pm UTC](https://discourse.julialang.org/t/multi-threading-or-multi-processing-with-iterators/21834 "2019-03-14T21:10:51Z")

</div>

How can one use multi-threading with general iterators. For ranges and arrays it’s very easy: using Threads result=Atomic{Int}(0) for i in 1:1000\_000 global result atomic\_add!(i) end # result.value == 500000500…

---

## [Chmod error on Dockers](https://discourse.julialang.org/t/chmod-error-on-dockers/21883)

<div class="topic-metadata">

**Author:** [@monty](https://discourse.julialang.org/u/monty)\
**Replies:** 1\
**Last updated:** [March 14, 2019, 9:08pm UTC](https://discourse.julialang.org/t/chmod-error-on-dockers/21883 "2019-03-14T21:08:41Z")

</div>

Any idea what this might be?! It occurs with julia 1.1; no problem with 0.7. IOError: chmod: no such file or directory (ENOENT) Stacktrace: \[1\] uv\_error at ./libuv.jl:85 \[inlined\] \[2\] #chmod#16(::Bool, ::Function, ::S…

---

## [Maximum for SArray](https://discourse.julialang.org/t/maximum-for-sarray/21885)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [March 14, 2019, 8:16pm UTC](https://discourse.julialang.org/t/maximum-for-sarray/21885 "2019-03-14T20:16:15Z")

</div>

Is there a way to call maximum along multiple dimensions so that it works for StaticArrays.SArray, and also in a type-stable way? MWE: # setup code using StaticArrays dims = (2,3,5) A = randn(dims...) SA = SArray(Size(d…

---

## [Fast Dict value modification by accessing Dict.vals](https://discourse.julialang.org/t/fast-dict-value-modification-by-accessing-dict-vals/21277)

<div class="topic-metadata">

**Author:** [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Replies:** 16\
**Last updated:** [March 14, 2019, 5:43pm UTC](https://discourse.julialang.org/t/fast-dict-value-modification-by-accessing-dict-vals/21277 "2019-03-14T17:43:34Z")

</div>

I have a use case that needs to blindly change the values stored in a Dict without worrying about the keys and do so quickly. The solution is effective: function dict\_value\_shift!(d::Dict{Ti,Tv},shift::Tv) where Ti whe…

---

## [MethodError: no method matching binomial](https://discourse.julialang.org/t/methoderror-no-method-matching-binomial/21874)

<div class="topic-metadata">

**Author:** [@Aquaman](https://discourse.julialang.org/u/Aquaman)\
**Replies:** 4\
**Last updated:** [March 14, 2019, 5:25pm UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-binomial/21874 "2019-03-14T17:25:32Z")

</div>

Dear all, How can I fix MethodError: no method matching binomial: pr = 5.6783 for i = 1:round(pr/2) n = 1/binomial(pr,i) end Best

---

## [JLD2: Loading file gives UnsupportedVersionException()](https://discourse.julialang.org/t/jld2-loading-file-gives-unsupportedversionexception/21878)

<div class="topic-metadata">

**Author:** [@GoodNews](https://discourse.julialang.org/u/GoodNews)\
**Replies:** 0\
**Last updated:** [March 14, 2019, 5:00pm UTC](https://discourse.julialang.org/t/jld2-loading-file-gives-unsupportedversionexception/21878 "2019-03-14T17:00:52Z")

</div>

Dear community, I am trying to save an array and afterwords load it into the program again on the same machine. For that I use JLD2 (v0.1.2) and Julia 1.0.3. This works for several array types and sizes but it fails fo…

---

## [Create A Matrix in Julia](https://discourse.julialang.org/t/create-a-matrix-in-julia/21538)

<div class="topic-metadata">

**Author:** [@Aquaman](https://discourse.julialang.org/u/Aquaman)\
**Replies:** 22\
**Last updated:** [March 14, 2019, 2:03pm UTC](https://discourse.julialang.org/t/create-a-matrix-in-julia/21538 "2019-03-14T14:03:23Z")

</div>

How to creat such matrix in Julia: CCP\[:,:,1\]= zeros(2,2) CCP\[:,:,2\]= zeros(2,2) CCP\[:,:,3\] = zeros(2,2) CCP\[:,:,4\] = zeros(2,2) this method works in matlab, but not in JUlia, namely ERROR: LoadError: UndefVarE…

---

## [Broadcasting across a nested array](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 47\
**Last updated:** [March 14, 2019, 7:49am UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700 "2019-03-14T07:49:28Z")

</div>

I was expecting the following to work: julia\> \[10, 100\] .+ \[\[5, 5\], \[6, 6\], \[7, 7\]\] ERROR: DimensionMismatch("arrays could not be broadcast to a common size") What is the correct syntax? Or is broadcasting only suppor…

---

## [Writing papers to 'docx'](https://discourse.julialang.org/t/writing-papers-to-docx/21835)

<div class="topic-metadata">

**Author:** [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Replies:** 1\
**Last updated:** [March 14, 2019, 7:47am UTC](https://discourse.julialang.org/t/writing-papers-to-docx/21835 "2019-03-14T07:47:11Z")

</div>

I’m trying to finish writing up a grant and I’m collaborating with people that specifically want a ‘docx’ format. It seems like I should be able to do this using Weave, but I can’t figure it out. Do I absolutely need to …

---

## [SharedArray on multiple nodes?](https://discourse.julialang.org/t/sharedarray-on-multiple-nodes/21847)

<div class="topic-metadata">

**Author:** [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Replies:** 0\
**Last updated:** [March 14, 2019, 1:58am UTC](https://discourse.julialang.org/t/sharedarray-on-multiple-nodes/21847 "2019-03-14T01:58:02Z")

</div>

I am considering using shared array to distribute large amounts of data to child processes in multiprocessing. However, I begin to wonder whether this will work for multiprocessing across computing nodes. Presumably, sha…

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

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