# General Usage

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

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

**Page:** 536

---

## [Use LaTeX package in Pluto](https://discourse.julialang.org/t/use-latex-package-in-pluto/68960)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 9\
**Last updated:** [October 12, 2021, 10:39am UTC](https://discourse.julialang.org/t/use-latex-package-in-pluto/68960 "2021-10-12T10:39:54Z")

</div>

Is it possible to use a latex package in Pluto?

---

## [Problem with shared library interfacing hardware devices](https://discourse.julialang.org/t/problem-with-shared-library-interfacing-hardware-devices/69612)

<div class="topic-metadata">

**Author:** [@Bossax](https://discourse.julialang.org/u/Bossax)\
**Replies:** 0\
**Last updated:** [October 12, 2021, 9:44am UTC](https://discourse.julialang.org/t/problem-with-shared-library-interfacing-hardware-devices/69612 "2021-10-12T09:44:59Z")

</div>

Hi all, I am using Julia to control a camera which comes with a shared library on Linux-Mint. The shared library provides APIs written in C++ . There are also header files containing definitions of types and constants c…

---

## [Transducer allocations](https://discourse.julialang.org/t/transducer-allocations/69573)

<div class="topic-metadata">

**Author:** [@astadmistry](https://discourse.julialang.org/u/astadmistry)\
**Replies:** 1\
**Last updated:** [October 12, 2021, 7:40am UTC](https://discourse.julialang.org/t/transducer-allocations/69573 "2021-10-12T07:40:55Z")

</div>

I’m trying to use transducers to do data manipulation such as computing a rolling simple moving average. The code works fine, however why is the code allocating memory when I’ve pre allocated it already? (look at last tw…

---

## [TL;DR tips for Julia users coming from Matlab](https://discourse.julialang.org/t/tl-dr-tips-for-julia-users-coming-from-matlab/41093)

<div class="topic-metadata">

**Author:** [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Replies:** 28\
**Last updated:** [October 11, 2021, 4:44pm UTC](https://discourse.julialang.org/t/tl-dr-tips-for-julia-users-coming-from-matlab/41093 "2021-10-11T16:44:40Z")

</div>

While the Julia Discourse and Slack communities are incredibly helpful, the responses can lean more technical. I thought it’d be nice to collect TL;DR advice for Julia summarized in simple terms. For example, in this th…

---

## [Display of a sparse matrix with all elements equal to zero](https://discourse.julialang.org/t/display-of-a-sparse-matrix-with-all-elements-equal-to-zero/69606)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 0\
**Last updated:** [October 12, 2021, 5:54am UTC](https://discourse.julialang.org/t/display-of-a-sparse-matrix-with-all-elements-equal-to-zero/69606 "2021-10-12T05:54:04Z")

</div>

Currently, a sparse matrix spy display prints a blank page if all the elements are zero. julia\> sparse(zeros(2, 2)) 2×2 SparseMatrixCSC{Float64, Int64} with 0 stored entries: ⋅ ⋅ ⋅ ⋅ julia\> sparse(zeros(20,…

---

## [Reading lines from a pipe without hanging at the end](https://discourse.julialang.org/t/reading-lines-from-a-pipe-without-hanging-at-the-end/69524)

<div class="topic-metadata">

**Author:** [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Replies:** 3\
**Last updated:** [October 12, 2021, 4:01am UTC](https://discourse.julialang.org/t/reading-lines-from-a-pipe-without-hanging-at-the-end/69524 "2021-10-12T04:01:02Z")

</div>

Suppose you want to run a command, read the output, and return some processed version of the output… for example this code parses the output of “traceroute”… function gethops(dname) trin = Pipe() trout = Pipe…

---

## [Addprocs error](https://discourse.julialang.org/t/addprocs-error/69458)

<div class="topic-metadata">

**Author:** [@pmarg](https://discourse.julialang.org/u/pmarg)\
**Replies:** 3\
**Last updated:** [October 12, 2021, 1:23am UTC](https://discourse.julialang.org/t/addprocs-error/69458 "2021-10-12T01:23:06Z")

</div>

I just installed Julia on a new PC and cannot add more than 7 workers. The PC has 32 cores and if use addprocs(32) Julia crashes. julia\> addprocs(1) 1-element Vector{Int64}: 2 julia\> addprocs(1) 1-element Vector{Int64…

---

## [@threads uses only half the number of nthreads()](https://discourse.julialang.org/t/threads-uses-only-half-the-number-of-nthreads/54058)

<div class="topic-metadata">

**Author:** [@msekino](https://discourse.julialang.org/u/msekino)\
**Replies:** 10\
**Last updated:** [October 12, 2021, 12:58am UTC](https://discourse.julialang.org/t/threads-uses-only-half-the-number-of-nthreads/54058 "2021-10-12T00:58:07Z")

</div>

Recently I built a PC with Ryzen Threadripper 3990X, which has 64 cores and 128 threads. The OS is Windows 10 Pro. When I tried the code below, only 64 threads reached 100% as shown in the attached image. Why aren’t a…

---

## [Birthday in Pi](https://discourse.julialang.org/t/birthday-in-pi/69590)

<div class="topic-metadata">

**Author:** [@Jesus-117](https://discourse.julialang.org/u/Jesus-117)\
**Replies:** 1\
**Last updated:** [October 11, 2021, 11:54pm UTC](https://discourse.julialang.org/t/birthday-in-pi/69590 "2021-10-11T23:54:11Z")

</div>

Hi! , recently I have been curious about how to do exercises from MatLab to Julia and I started doing the birthday day in pi, in MatLab there is the function “SequencePosition” that helps in this type of problems. My que…

---

## [A Question about struct](https://discourse.julialang.org/t/a-question-about-struct/69582)

<div class="topic-metadata">

**Author:** [@IsraelSI](https://discourse.julialang.org/u/IsraelSI)\
**Replies:** 1\
**Last updated:** [October 11, 2021, 7:31pm UTC](https://discourse.julialang.org/t/a-question-about-struct/69582 "2021-10-11T19:31:50Z")

</div>

Sorry, I’m new to Julia and I have a little conflict with the structures, for example if I have 2 structures corresponding to a polygon and a segment. tstruct segment first\_vertex::Array second\_vertex::Array …

---

## [Why NTuple{2, Ref{Int}} \<: NTuple get false?](https://discourse.julialang.org/t/why-ntuple-2-ref-int-ntuple-get-false/69559)

<div class="topic-metadata">

**Author:** [@zwtechnb](https://discourse.julialang.org/u/zwtechnb)\
**Replies:** 7\
**Last updated:** [October 11, 2021, 7:23pm UTC](https://discourse.julialang.org/t/why-ntuple-2-ref-int-ntuple-get-false/69559 "2021-10-11T19:23:07Z")

</div>

Code: julia\> NTuple{2, Int} \<: NTuple true julia\> NTuple{2, Ref{Int}} \<: NTuple false julia\> (NTuple{2, T} where T) \<: NTuple true

---

## [How to define a numerical value in Julia?](https://discourse.julialang.org/t/how-to-define-a-numerical-value-in-julia/69574)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 5\
**Last updated:** [October 11, 2021, 6:47pm UTC](https://discourse.julialang.org/t/how-to-define-a-numerical-value-in-julia/69574 "2021-10-11T18:47:46Z")

</div>

I keep getting the below error: LoadError: UndefVarError: n1 not defined for my below code: n1 = 0; for i in 1:m\[1\], j in 1:m\[2\] n1 += 1; A\[n1,:\] = \[X0\[i,j\] Y0\[i,j\] E0\[i,j\]\]; end Hasn’t my “n1=0;” def…

---

## [Making a fast evaluation of a function and its gradient](https://discourse.julialang.org/t/making-a-fast-evaluation-of-a-function-and-its-gradient/68884)

<div class="topic-metadata">

**Author:** [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Replies:** 32\
**Last updated:** [October 11, 2021, 5:32pm UTC](https://discourse.julialang.org/t/making-a-fast-evaluation-of-a-function-and-its-gradient/68884 "2021-10-11T17:32:33Z")

</div>

Hi everybody, I have written a script that evaluates a non-linear function feta over a 2D domain. The function returns eta that depends on other 2D fields (Exx, Eyy, Exy). I try to compute the gradient of eta w.r.t Exx…

---

## [Zygote: how to get intermediate values without evaluating function twice?](https://discourse.julialang.org/t/zygote-how-to-get-intermediate-values-without-evaluating-function-twice/69126)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 4\
**Last updated:** [October 11, 2021, 5:17pm UTC](https://discourse.julialang.org/t/zygote-how-to-get-intermediate-values-without-evaluating-function-twice/69126 "2021-10-11T17:17:17Z")

</div>

Perhaps my issue is best illustrated with a toy example. I have a function loss(x, y, z). This function returns a scalar value MSE; however, it also calculates some intermediate values during the computation, which I als…

---

## [What is the meaning of: while false end](https://discourse.julialang.org/t/what-is-the-meaning-of-while-false-end/69507)

<div class="topic-metadata">

**Author:** [@eliascarv](https://discourse.julialang.org/u/eliascarv)\
**Replies:** 7\
**Last updated:** [October 11, 2021, 3:05pm UTC](https://discourse.julialang.org/t/what-is-the-meaning-of-while-false-end/69507 "2021-10-11T15:05:39Z")

</div>

I’ve seen this line of code used in some packages and Julia source code: while false end I assume it’s used for precompilation, but I’m not sure. Could someone explain what the purpose of this line of code is?

---

## [Distributing a function that uses FFTW](https://discourse.julialang.org/t/distributing-a-function-that-uses-fftw/69564)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 1\
**Last updated:** [October 11, 2021, 2:57pm UTC](https://discourse.julialang.org/t/distributing-a-function-that-uses-fftw/69564 "2021-10-11T14:57:30Z")

</div>

Hi! I’ve been having a lot of trouble using pmap with a function that uses FFTW with a planned FFT. Here is a minimum example, where I just try to perform a FFT on an array of matrices: @everywhere using FFTW using Dist…

---

## [Performance difference in permuting Arrays](https://discourse.julialang.org/t/performance-difference-in-permuting-arrays/69425)

<div class="topic-metadata">

**Author:** [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Replies:** 4\
**Last updated:** [October 11, 2021, 1:23pm UTC](https://discourse.julialang.org/t/performance-difference-in-permuting-arrays/69425 "2021-10-11T13:23:04Z")

</div>

Hi guys, I am trying to permute/shuffle a Vector of Vectors given a certain index. Some vectors can occur several times, so I need a buffer container for no allocations. MWE: vals = \[ \[1, 2, 3\], \[4, 5, 6\], \[7, 8, 9\] \] …

---

## [Trying to Use PackageCompiler.jl](https://discourse.julialang.org/t/trying-to-use-packagecompiler-jl/69275)

<div class="topic-metadata">

**Author:** [@chelseas](https://discourse.julialang.org/u/chelseas)\
**Replies:** 8\
**Last updated:** [October 11, 2021, 11:59am UTC](https://discourse.julialang.org/t/trying-to-use-packagecompiler-jl/69275 "2021-10-11T11:59:42Z")

</div>

I’m trying to use packagecompiler.jl and I don’t know what I’m doing wrong: (NNFuelGage.jl) pkg\> julia\> using Interpolations julia\> using JuMP julia\> using LazySets usin julia\> using MathOptInterface julia\> using G…

---

## [How do we exec a julia program for competitive programming?](https://discourse.julialang.org/t/how-do-we-exec-a-julia-program-for-competitive-programming/25470)

<div class="topic-metadata">

**Author:** [@p1scescom](https://discourse.julialang.org/u/p1scescom)\
**Replies:** 2\
**Last updated:** [October 11, 2021, 8:38am UTC](https://discourse.julialang.org/t/how-do-we-exec-a-julia-program-for-competitive-programming/25470 "2021-10-11T08:38:57Z")

</div>

Hey everyone. I want your idea to exec a julia program quickly and usefuly for competitive prgramming. You may not know competitive programming. It is A programming competition generally involves the host presenting…

---

## [Unable to load Queryverse](https://discourse.julialang.org/t/unable-to-load-queryverse/69539)

<div class="topic-metadata">

**Author:** [@PAHH](https://discourse.julialang.org/u/PAHH)\
**Replies:** 0\
**Last updated:** [October 11, 2021, 4:59am UTC](https://discourse.julialang.org/t/unable-to-load-queryverse/69539 "2021-10-11T04:59:46Z")

</div>

Hi all, I’m using Julia 1.6.3 (VS Code 1.61.0) and am unable to use the Queryverse package. I first tried to load it onto my current environment (which also contains StatsKit among other things), but then I tried to load…

---

## [Large memory allocation when a loop is threaded, none when run single-threaded](https://discourse.julialang.org/t/large-memory-allocation-when-a-loop-is-threaded-none-when-run-single-threaded/69535)

<div class="topic-metadata">

**Author:** [@Chris\_Green](https://discourse.julialang.org/u/Chris_Green)\
**Replies:** 12\
**Last updated:** [October 11, 2021, 4:31am UTC](https://discourse.julialang.org/t/large-memory-allocation-when-a-loop-is-threaded-none-when-run-single-threaded/69535 "2021-10-11T04:31:42Z")

</div>

I have a simple volume rendering loop coded in julia. It uses fixed size 3d vector classes based around the StaticArrays package, derive from FieldVector: struct Vector3D{T} \<: FieldVector{3, T} x::T y::T z:…

---

## [Dictionaries can't find keys](https://discourse.julialang.org/t/dictionaries-cant-find-keys/69488)

<div class="topic-metadata">

**Author:** [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Replies:** 34\
**Last updated:** [October 10, 2021, 8:56pm UTC](https://discourse.julialang.org/t/dictionaries-cant-find-keys/69488 "2021-10-10T20:56:40Z")

</div>

I have this dictionary starting\_balance=starting\_balance=Dict( # Starting Balance consists of a dictionary, containing debit and credit dictionaries, containing accounts as empty dictionaries. #accounts are organized…

---

## [Get all object field values as tuple](https://discourse.julialang.org/t/get-all-object-field-values-as-tuple/69517)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 2\
**Last updated:** [October 10, 2021, 7:30pm UTC](https://discourse.julialang.org/t/get-all-object-field-values-as-tuple/69517 "2021-10-10T19:30:57Z")

</div>

Hellow! how can i get all object field values as tuple better as this: object\_field\_values = (getproperty.(repeat(\[object\],fieldcount(T)), fieldnames(T))...,)

---

## [Cholesky simple example](https://discourse.julialang.org/t/cholesky-simple-example/69480)

<div class="topic-metadata">

**Author:** [@Jakub\_Mitura](https://discourse.julialang.org/u/Jakub_Mitura)\
**Replies:** 11\
**Last updated:** [October 10, 2021, 6:19pm UTC](https://discourse.julialang.org/t/cholesky-simple-example/69480 "2021-10-10T18:19:20Z")

</div>

Hello I try to implement from basis (I need it for GPU kernel (just small 3 by 3 matrix one of multiple things that a kernel do - no point in using cublas …) so -can not using Linear algebra package for a moment , als…

---

## [Override default object display length in REPL/env?](https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246)

<div class="topic-metadata">

**Author:** [@marerik](https://discourse.julialang.org/u/marerik)\
**Replies:** 7\
**Last updated:** [October 10, 2021, 3:54pm UTC](https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246 "2021-10-10T15:54:28Z")

</div>

If I want to display a large object (vector, array, matrix, etc) in the REPL, it will typically echo/display it, but incompletely with ellipses denoting the undisplayed/suppressed values. Is there a way to override the …

---

## [Random Sampler behavior](https://discourse.julialang.org/t/random-sampler-behavior/69512)

<div class="topic-metadata">

**Author:** [@goncharovdk](https://discourse.julialang.org/u/goncharovdk)\
**Replies:** 4\
**Last updated:** [October 10, 2021, 3:21pm UTC](https://discourse.julialang.org/t/random-sampler-behavior/69512 "2021-10-10T15:21:51Z")

</div>

Hello. I’m now rewriting some Monte Carlo simulation code from Java to Julia. It probably was a bad idea to implement it in Java in the first place, but now I use results calculated by Java implementation to verify the c…

---

## [Undef for non-arrays](https://discourse.julialang.org/t/undef-for-non-arrays/69250)

<div class="topic-metadata">

**Author:** [@goerch](https://discourse.julialang.org/u/goerch)\
**Replies:** 6\
**Last updated:** [October 10, 2021, 3:15pm UTC](https://discourse.julialang.org/t/undef-for-non-arrays/69250 "2021-10-10T15:15:51Z")

</div>

Do we have something similar to undef for non-arrays? Wishful thinking: f() = a::Tuple{Int, Int} where T = 5, undef

---

## [Create a struct with uninitialized fields](https://discourse.julialang.org/t/create-a-struct-with-uninitialized-fields/6967)

<div class="topic-metadata">

**Author:** [@dfdx](https://discourse.julialang.org/u/dfdx)\
**Replies:** 4\
**Last updated:** [October 10, 2021, 2:08pm UTC](https://discourse.julialang.org/t/create-a-struct-with-uninitialized-fields/6967 "2021-10-10T14:08:06Z")

</div>

Having a mutable struct, e.g.: mutable struct Point x y end is it possible to construct its instance with uninitialized fields and set them later? E.g.: p = create\_uninitialized(Point) # \<-- anything like t…

---

## [How to put values like today() into a string?](https://discourse.julialang.org/t/how-to-put-values-like-today-into-a-string/69506)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 5\
**Last updated:** [October 10, 2021, 12:32pm UTC](https://discourse.julialang.org/t/how-to-put-values-like-today-into-a-string/69506 "2021-10-10T12:32:49Z")

</div>

For example, if I have a variable like this: A = "Dog"; B = "Cat"; I can do this: C = "I have both $A and $b"; How do I do something like the below and add today’s value, e.g., October 10, 2021? D = “I walked my $A …

---

## [LaTeX commands not working with LaTeXStrings eg \\mathfrak, \\boldsymbol](https://discourse.julialang.org/t/latex-commands-not-working-with-latexstrings-eg-mathfrak-boldsymbol/69448)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 3\
**Last updated:** [October 10, 2021, 12:06pm UTC](https://discourse.julialang.org/t/latex-commands-not-working-with-latexstrings-eg-mathfrak-boldsymbol/69448 "2021-10-10T12:06:22Z")

</div>

Hello, Some routines like \\boldsymbol or \\mathfrak don’t work for me with LaTeXStrings, while some others like \\mathsf or \\mathrm do. Is it due to my setup, or is it a limitation of LaTeXStrings? Do you know how to fix …

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

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