# General Usage

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

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

**Page:** 622

---

## [Docstring errors when building documentation](https://discourse.julialang.org/t/docstring-errors-when-building-documentation/57547)

<div class="topic-metadata">

**Author:** [@cadojo](https://discourse.julialang.org/u/cadojo)\
**Replies:** 1\
**Last updated:** [March 29, 2021, 11:40am UTC](https://discourse.julialang.org/t/docstring-errors-when-building-documentation/57547 "2021-03-29T11:40:59Z")

</div>

I’m trying to build documentation for a submodule in a public package. For some reason, I keep getting unable to get the binding for a bunch of functions in the ThreeBody submodule. The docstrings are provided in code, a…

---

## [Sqrt(abs(x)) is even faster than sqrt!](https://discourse.julialang.org/t/sqrt-abs-x-is-even-faster-than-sqrt/58154)

<div class="topic-metadata">

**Author:** [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Replies:** 11\
**Last updated:** [March 29, 2021, 11:26am UTC](https://discourse.julialang.org/t/sqrt-abs-x-is-even-faster-than-sqrt/58154 "2021-03-29T11:26:09Z")

</div>

I accidentally found that computing both sqrt and abs is even faster than sqrt alone. julia\> using BenchmarkTools julia\> sqrt\_abs(x) = sqrt(abs(x)); julia\> const N = 1000; julia\> const positive\_x = randn(N) .^ 2 .+ 1…

---

## [Can I use \\parallel or \\perp in variables' names](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 8\
**Last updated:** [March 29, 2021, 11:20am UTC](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120 "2021-03-29T11:20:40Z")

</div>

Some unicode symbols cannot be used in variables’ names. For example, julia\> C∥ = 1 ERROR: syntax: unexpected "=" Stacktrace: \[1\] top-level scope at none:1 julia\> C⟂ = 2 ERROR: syntax: unexpected "=" Stacktrace: \[1\]…

---

## [How to put a timestamp in a filename on Windows?](https://discourse.julialang.org/t/how-to-put-a-timestamp-in-a-filename-on-windows/58155)

<div class="topic-metadata">

**Author:** [@Olivier\_Merchiers](https://discourse.julialang.org/u/Olivier_Merchiers)\
**Replies:** 2\
**Last updated:** [March 29, 2021, 9:47am UTC](https://discourse.julialang.org/t/how-to-put-a-timestamp-in-a-filename-on-windows/58155 "2021-03-29T09:47:23Z")

</div>

Hello everyone, On linux I do this very common thing of putting a timestamp in the filenames that are produced by my simulations: a=1.0 b=1.5 using Dates filename =string(now())\*"\_parameter1=$(a)\_parameter2=$(b).txt" …

---

## [CartesianIndices gives different answer in Julia 1.6 and 1.5 for particular case](https://discourse.julialang.org/t/cartesianindices-gives-different-answer-in-julia-1-6-and-1-5-for-particular-case/58156)

<div class="topic-metadata">

**Author:** [@fverdugo](https://discourse.julialang.org/u/fverdugo)\
**Replies:** 1\
**Last updated:** [March 29, 2021, 9:30am UTC](https://discourse.julialang.org/t/cartesianindices-gives-different-answer-in-julia-1-6-and-1-5-for-particular-case/58156 "2021-03-29T09:30:56Z")

</div>

I just wanted to mention that I have noticed this change in the behavior of CartesianIndices. Which is the expected one, the new or the old? In Julia 1.5.3 julia\> CartesianIndices((2,1:3)) 1×3 CartesianIndices{2,Tuple{…

---

## [Why is there memory allocation and time difference in @views and view?](https://discourse.julialang.org/t/why-is-there-memory-allocation-and-time-difference-in-views-and-view/58149)

<div class="topic-metadata">

**Author:** [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Replies:** 9\
**Last updated:** [March 29, 2021, 8:07am UTC](https://discourse.julialang.org/t/why-is-there-memory-allocation-and-time-difference-in-views-and-view/58149 "2021-03-29T08:07:36Z")

</div>

Julia Version 1.5.3 julia\> f(a, b, c) = a + b - c; julia\> X = randn(1000, 5); julia\> y = zeros(1000); # feed the last three columns of \`X\` into \`f\` and write the result into \`y\` julia\> @btime $y .= f((view($X, :, j)…

---

## [Unsupported architecture 'aarch64' for macOS when adding Plots on Arm64 Linux](https://discourse.julialang.org/t/unsupported-architecture-aarch64-for-macos-when-adding-plots-on-arm64-linux/58134)

<div class="topic-metadata">

**Author:** [@MikeHutch](https://discourse.julialang.org/u/MikeHutch)\
**Replies:** 4\
**Last updated:** [March 28, 2021, 10:20pm UTC](https://discourse.julialang.org/t/unsupported-architecture-aarch64-for-macos-when-adding-plots-on-arm64-linux/58134 "2021-03-28T22:20:48Z")

</div>

I’ve build Julia 1.6.0 on my Raspberry Pi running 64bit Gentoo Linux. Everything appeared to be working fine until I tried to add Plots when I get an Unsupported architecture error, see below: import Pkg; Pkg.add("Plot…

---

## [Avoid allocation of small arrays in median, extrema, etc](https://discourse.julialang.org/t/avoid-allocation-of-small-arrays-in-median-extrema-etc/58075)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 23\
**Last updated:** [March 28, 2021, 9:45pm UTC](https://discourse.julialang.org/t/avoid-allocation-of-small-arrays-in-median-extrema-etc/58075 "2021-03-28T21:45:48Z")

</div>

I have a performance critical call to set bounds on a number. This code works like magic, but I want to know why it doesn’t need to allocate julia\> @benchmark clamp(v\[1\],extrema((v\[2\],v\[3\],v\[4\]))...) setup=(v=rand(4)) B…

---

## [Constructor of parametric types](https://discourse.julialang.org/t/constructor-of-parametric-types/58136)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 6\
**Last updated:** [March 28, 2021, 9:31pm UTC](https://discourse.julialang.org/t/constructor-of-parametric-types/58136 "2021-03-28T21:31:03Z")

</div>

I have the following two types. The second one is based on the first one. struct RankOneMatrix{T} \<: AbstractMatrix{T} v::AbstractVector{T} w::AbstractVector{T} end function Base.size(A::RankOneMatrix) retu…

---

## [Alternate argument types](https://discourse.julialang.org/t/alternate-argument-types/58114)

<div class="topic-metadata">

**Author:** [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Replies:** 3\
**Last updated:** [March 28, 2021, 6:42pm UTC](https://discourse.julialang.org/t/alternate-argument-types/58114 "2021-03-28T18:42:08Z")

</div>

Is there a macro or something that makes defining functions like this easier, where one or more of the arguments is of a given type? struct MyType \<: Number x::Float64 end f(a::MyType, b::MyType, c::MyType) = ... f…

---

## [Instantiation of a subtype of an abstract type](https://discourse.julialang.org/t/instantiation-of-a-subtype-of-an-abstract-type/58126)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 2\
**Last updated:** [March 28, 2021, 6:16pm UTC](https://discourse.julialang.org/t/instantiation-of-a-subtype-of-an-abstract-type/58126 "2021-03-28T18:16:27Z")

</div>

I’m following the MIT class “Introduction to Computational Thinking”, and have some trouble with the recent homework. (The class is amazing by the way. Any applied math course should be taught in this way IMO.) A struct…

---

## [Passing complex struct to C function results in segfault](https://discourse.julialang.org/t/passing-complex-struct-to-c-function-results-in-segfault/58100)

<div class="topic-metadata">

**Author:** [@oekenta](https://discourse.julialang.org/u/oekenta)\
**Replies:** 3\
**Last updated:** [March 28, 2021, 5:50pm UTC](https://discourse.julialang.org/t/passing-complex-struct-to-c-function-results-in-segfault/58100 "2021-03-28T17:50:32Z")

</div>

I’m trying to interface with a C API for solving linear systems but I keep running into segfault errors. The algorithm uses a somewhat complex C structure, called LUSOLrec, to keep track of all the relevant data. \_LUSOL…

---

## [After upgrading to 1.6 adding any package results in (non-breaking) MethodError](https://discourse.julialang.org/t/after-upgrading-to-1-6-adding-any-package-results-in-non-breaking-methoderror/58119)

<div class="topic-metadata">

**Author:** [@jonasjonker](https://discourse.julialang.org/u/jonasjonker)\
**Replies:** 0\
**Last updated:** [March 28, 2021, 3:07pm UTC](https://discourse.julialang.org/t/after-upgrading-to-1-6-adding-any-package-results-in-non-breaking-methoderror/58119 "2021-03-28T15:07:12Z")

</div>

I upgraded to 1.6, and from that moment on I got the following error when adding a package. However, the package just seems to be installed, and works fine. ERROR: MethodError: Cannot \`convert\` an object of type Noth…

---

## [Performance of norm function](https://discourse.julialang.org/t/performance-of-norm-function/14709)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 21\
**Last updated:** [March 28, 2021, 1:15pm UTC](https://discourse.julialang.org/t/performance-of-norm-function/14709 "2021-03-28T13:15:49Z")

</div>

Custom for-loop seems 3x faster than LinearAlgebra’s norm… julia\> using LinearAlgebra, BenchmarkTools julia\> A = rand(5,5); julia\> function foo1(A) x = zero(eltype(A)) for v in A x += v \*…

---

## [Use band-storage jacobian with CVODE\_BDF in OrdinaryDiffEq](https://discourse.julialang.org/t/use-band-storage-jacobian-with-cvode-bdf-in-ordinarydiffeq/58068)

<div class="topic-metadata">

**Author:** [@Nicholaswogan](https://discourse.julialang.org/u/Nicholaswogan)\
**Replies:** 4\
**Last updated:** [March 28, 2021, 2:07am UTC](https://discourse.julialang.org/t/use-band-storage-jacobian-with-cvode-bdf-in-ordinarydiffeq/58068 "2021-03-28T02:07:21Z")

</div>

I am trying to solve a large system of ODEs. The jacobian of these ODEs is a band matrix. Is it possible to feed the CVODE\_BDF algorithm, from Sundials.jl, a function for the jacobian which returns the jacobian in band s…

---

## [Performance regression with SAs as parameters in DiffEqs on Julia 1.6](https://discourse.julialang.org/t/performance-regression-with-sas-as-parameters-in-diffeqs-on-julia-1-6/58103)

<div class="topic-metadata">

**Author:** [@dcabecinhas](https://discourse.julialang.org/u/dcabecinhas)\
**Replies:** 0\
**Last updated:** [March 28, 2021, 1:32am UTC](https://discourse.julialang.org/t/performance-regression-with-sas-as-parameters-in-diffeqs-on-julia-1-6/58103 "2021-03-28T01:32:33Z")

</div>

Hi all, I have some code where I pass parameters to ODE problems and it had some performance regressions with Julia 1.6. I distilled the code to highlight what seems to me to be at the root of the problem - passing Sta…

---

## [ControlSystems -- transfer functions with delay?](https://discourse.julialang.org/t/controlsystems-transfer-functions-with-delay/58003)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 12\
**Last updated:** [March 27, 2021, 9:24pm UTC](https://discourse.julialang.org/t/controlsystems-transfer-functions-with-delay/58003 "2021-03-27T21:24:24Z")

</div>

From the documentation: ControlSystems.tf — Function. sys = tf(num, den, Ts=0), sys = tf(gain, Ts=0) → Is it possible to define a time delay for functions tf and zpk? I’m trying to “sell” Julia to a friend, and he…

---

## [V1.6 Package manager issue](https://discourse.julialang.org/t/v1-6-package-manager-issue/58054)

<div class="topic-metadata">

**Author:** [@monty](https://discourse.julialang.org/u/monty)\
**Replies:** 22\
**Last updated:** [March 27, 2021, 9:08pm UTC](https://discourse.julialang.org/t/v1-6-package-manager-issue/58054 "2021-03-27T21:08:40Z")

</div>

The new version v1.6 creates strange problems with my packages which I can’t fix. For example: (@v1.6) pkg\> st JLD2 Status \`~/.julia/environments/v1.6/Project.toml\` \[033835bb\] JLD2 v0.3.3 (@v1.6) pkg\> up ERROR…

---

## [A function like copyto! that acts recursively as deepcopy](https://discourse.julialang.org/t/a-function-like-copyto-that-acts-recursively-as-deepcopy/58027)

<div class="topic-metadata">

**Author:** [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Replies:** 12\
**Last updated:** [March 27, 2021, 6:46pm UTC](https://discourse.julialang.org/t/a-function-like-copyto-that-acts-recursively-as-deepcopy/58027 "2021-03-27T18:46:00Z")

</div>

Recently I stumbled upon a case where I for example have an array of arrays (a) and a second memory already allocated (b) – this might also be deeper nested than in the following example. a = \[\[1\],\[2\],\[3\]\] b = similar.(…

---

## [Julia vs. Java on embedded](https://discourse.julialang.org/t/julia-vs-java-on-embedded/58032)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 2\
**Last updated:** [March 27, 2021, 4:39pm UTC](https://discourse.julialang.org/t/julia-vs-java-on-embedded/58032 "2021-03-27T16:39:13Z")

</div>

We are working with an embedded device similar to a Pi 3 (well, perhaps in one or two years like a Pi 4) and use Java for our GUI application. We have now 2GB RAM, extending that to 4GB would be possible. Perhaps as cla…

---

## [Multiple Module Packages and Project Environment](https://discourse.julialang.org/t/multiple-module-packages-and-project-environment/58079)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 2\
**Last updated:** [March 27, 2021, 4:36pm UTC](https://discourse.julialang.org/t/multiple-module-packages-and-project-environment/58079 "2021-03-27T16:36:12Z")

</div>

I’ve seen a few other posts on this one, but they don’t seem to quite address the question I have. I have a project I’m working on, and there are several logically distinct modules associated with it, MyModuleA.jl, MyMo…

---

## [Julia 1.6 versus 1.5.4](https://discourse.julialang.org/t/julia-1-6-versus-1-5-4/57993)

<div class="topic-metadata">

**Author:** [@jovansam](https://discourse.julialang.org/u/jovansam)\
**Replies:** 8\
**Last updated:** [March 26, 2021, 12:12pm UTC](https://discourse.julialang.org/t/julia-1-6-versus-1-5-4/57993 "2021-03-26T12:12:38Z")

</div>

I find that Julia 1.5.4 is faster in some use cases than 1.6. Do others experience this? What is the explanation. Below is a piece of code that illustrates this. It finds the value function for an optimal growth problem…

---

## [Weird Sys.which() function](https://discourse.julialang.org/t/weird-sys-which-function/58070)

<div class="topic-metadata">

**Author:** [@j2b2](https://discourse.julialang.org/u/j2b2)\
**Replies:** 3\
**Last updated:** [March 27, 2021, 2:53pm UTC](https://discourse.julialang.org/t/weird-sys-which-function/58070 "2021-03-27T14:53:43Z")

</div>

Hi, IJulia doesn’t work on my system, Ubuntu LTS 20.04. The (bash) command jupyter notebook works fine, but I don’t see julia when I press the “new” button. So I launched julia REPL and tried : julia\> using IJulia juli…

---

## [Preventing collect on broadcasting expressions](https://discourse.julialang.org/t/preventing-collect-on-broadcasting-expressions/57996)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 6\
**Last updated:** [March 27, 2021, 2:22pm UTC](https://discourse.julialang.org/t/preventing-collect-on-broadcasting-expressions/57996 "2021-03-27T14:22:20Z")

</div>

In writing efficient code for image processing, views are incredibly useful. They can nicely be chained for example to implement a phasor in optics propagation: using IndexFunArrays k0 = 5; phasor = exp.(1im .\* 2pi .\*sq…

---

## [Which size for subplots (Plots.jl/GR)](https://discourse.julialang.org/t/which-size-for-subplots-plots-jl-gr/53936)

<div class="topic-metadata">

**Author:** [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Replies:** 5\
**Last updated:** [March 27, 2021, 1:40pm UTC](https://discourse.julialang.org/t/which-size-for-subplots-plots-jl-gr/53936 "2021-03-27T13:40:42Z")

</div>

I have 12 plots of size (400px,400px). Each one individually looks fine. But when composing them into a grid(1,12), they start to overlap and the y-labels and ticks have too much distance for the y-axis. I know that I…

---

## [Managing Julia installation on Windows](https://discourse.julialang.org/t/managing-julia-installation-on-windows/58074)

<div class="topic-metadata">

**Author:** [@SL6Trip](https://discourse.julialang.org/u/SL6Trip)\
**Replies:** 0\
**Last updated:** [March 27, 2021, 12:20pm UTC](https://discourse.julialang.org/t/managing-julia-installation-on-windows/58074 "2021-03-27T12:20:39Z")

</div>

So recently I came across jill.py which seems to be using Python to help with automating the installation and/or upgrading of Julia to newer releases. I think it is a great tool especially on Linux distributions (as I te…

---

## [Problem plotting surfaces](https://discourse.julialang.org/t/problem-plotting-surfaces/58065)

<div class="topic-metadata">

**Author:** [@leopdsf](https://discourse.julialang.org/u/leopdsf)\
**Replies:** 2\
**Last updated:** [March 27, 2021, 12:18pm UTC](https://discourse.julialang.org/t/problem-plotting-surfaces/58065 "2021-03-27T12:18:22Z")

</div>

Hello, there! I’m plotting a surface with the following code: using Plots θ = 1.5 K = J/θ #3D plot y=range(-2,stop=2) θ=range(0.1,stop=2) function f(y,θ) J = 1.0 h = 0.0 -θ\*log(2.0) -θ\*log(exp(-(J/θ)\*y^2/2…

---

## [Tullio with LoopVectorization fails with upgrade to 1.6.0](https://discourse.julialang.org/t/tullio-with-loopvectorization-fails-with-upgrade-to-1-6-0/58028)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 11\
**Last updated:** [March 27, 2021, 12:12pm UTC](https://discourse.julialang.org/t/tullio-with-loopvectorization-fails-with-upgrade-to-1-6-0/58028 "2021-03-27T12:12:27Z")

</div>

The following code runs fine on Julia 1.5.3, but fails on 1.6.0. It fails on the Tullio line with error ERROR: LoadError: BoundsError: attempt to access 2-element Vector{Any} at index \[0\] If I disable LoopVectorizatio…

---

## [Factor out field access of \`AbstractArray\` and/or iterator interface](https://discourse.julialang.org/t/factor-out-field-access-of-abstractarray-and-or-iterator-interface/41493)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 5\
**Last updated:** [March 27, 2021, 2:44am UTC](https://discourse.julialang.org/t/factor-out-field-access-of-abstractarray-and-or-iterator-interface/41493 "2021-03-27T02:44:51Z")

</div>

Take function foo(a) for x in a x.field # do something with x.field end end function foo2(a) for x in a x # do something with x directly end end The foo2 version accesses elements direc…

---

## [Which is the most efficient way to add matrices/arrays in Julia 1.x?](https://discourse.julialang.org/t/which-is-the-most-efficient-way-to-add-matrices-arrays-in-julia-1-x/39602)

<div class="topic-metadata">

**Author:** [@KZiemian](https://discourse.julialang.org/u/KZiemian)\
**Replies:** 11\
**Last updated:** [March 26, 2021, 8:17pm UTC](https://discourse.julialang.org/t/which-is-the-most-efficient-way-to-add-matrices-arrays-in-julia-1-x/39602 "2021-03-26T20:17:58Z")

</div>

Adding matrices is very important thing in numerical computations and I fell that discusion of results of benchmarking this in Julia 1.x should take place here. Because I don’t find such topic on Julia Discourse I put wh…

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

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