# General Usage

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

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

**Page:** 331

---

## [Vectorization heuristics are hard! Is there a way to ask/get more information to/from the compiler/LLVM about loop vectorization](https://discourse.julialang.org/t/vectorization-heuristics-are-hard-is-there-a-way-to-ask-get-more-information-to-from-the-compiler-llvm-about-loop-vectorization/94432)

<div class="topic-metadata">

**Author:** [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Replies:** 2\
**Last updated:** [February 10, 2023, 10:11pm UTC](https://discourse.julialang.org/t/vectorization-heuristics-are-hard-is-there-a-way-to-ask-get-more-information-to-from-the-compiler-llvm-about-loop-vectorization/94432 "2023-02-10T22:11:21Z")

</div>

In the PR below, we have made a lot of progress speeding up isascii with something as simple as essentially: (which is faster than using UInt64) function \_isascii(cu::AbstractVector{CU}, first, last) where {CU} r = …

---

## [Converting row major to column major in 3 (or more) dimensions](https://discourse.julialang.org/t/converting-row-major-to-column-major-in-3-or-more-dimensions/94434)

<div class="topic-metadata">

**Author:** [@Robert\_Aronoff](https://discourse.julialang.org/u/Robert_Aronoff)\
**Replies:** 2\
**Last updated:** [February 10, 2023, 10:05pm UTC](https://discourse.julialang.org/t/converting-row-major-to-column-major-in-3-or-more-dimensions/94434 "2023-02-10T22:05:06Z")

</div>

I have a use case where I receive an array (pointer) back from a C library. The C array is converted to a Julia array with unsafe\_wrap. Every thing is fine with 1 and 2 dimensional arrays. Unsafe\_wrap assumes the sourc…

---

## [What's using up so much memory?](https://discourse.julialang.org/t/whats-using-up-so-much-memory/69712)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 12\
**Last updated:** [February 10, 2023, 8:53pm UTC](https://discourse.julialang.org/t/whats-using-up-so-much-memory/69712 "2023-02-10T20:53:19Z")

</div>

After loading some data into a DataFrame using LibPQ, I can see from htop that the Julia process is using 9.5 GB of resident memory, which doesn’t shrink even after running the garbage collector. I only have 1.2 GB of v…

---

## [CodeCov doesn't see @recipe macro](https://discourse.julialang.org/t/codecov-doesnt-see-recipe-macro/94433)

<div class="topic-metadata">

**Author:** [@jared711](https://discourse.julialang.org/u/jared711)\
**Replies:** 0\
**Last updated:** [February 10, 2023, 8:44pm UTC](https://discourse.julialang.org/t/codecov-doesnt-see-recipe-macro/94433 "2023-02-10T20:44:13Z")

</div>

I’ve been trying to get my code coverage to 100% in my package ThreeBodyProblem.jl\[GitHub - jared711/ThreeBodyProblem.jl: An astrodynamics package for working in the three body problem\] The last thing left that isn’t co…

---

## [MethodError: Convert Ref value between GPU and CPU](https://discourse.julialang.org/t/methoderror-convert-ref-value-between-gpu-and-cpu/94426)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 0\
**Last updated:** [February 10, 2023, 7:07pm UTC](https://discourse.julialang.org/t/methoderror-convert-ref-value-between-gpu-and-cpu/94426 "2023-02-10T19:07:45Z")

</div>

Can anyone teach me how to overload the convert function to remove this error, using CUDA? MethodError: Cannot \`convert\` an object of type CUDA.CuRefValue{Int64} to an object of type Base.RefValue{Int64} Kind regards

---

## [Two separate vectors of same length and eliminating items in both vectors, whenever the values of those vectors are the same at identical columns. Depending on this the values of a third vector shall be eliminated accordingly](https://discourse.julialang.org/t/two-separate-vectors-of-same-length-and-eliminating-items-in-both-vectors-whenever-the-values-of-those-vectors-are-the-same-at-identical-columns-depending-on-this-the-values-of-a-third-vector-shall-be-eliminated-accordingly/94371)

<div class="topic-metadata">

**Author:** [@ratwolf](https://discourse.julialang.org/u/ratwolf)\
**Replies:** 1\
**Last updated:** [February 9, 2023, 7:35pm UTC](https://discourse.julialang.org/t/two-separate-vectors-of-same-length-and-eliminating-items-in-both-vectors-whenever-the-values-of-those-vectors-are-the-same-at-identical-columns-depending-on-this-the-values-of-a-third-vector-shall-be-eliminated-accordingly/94371 "2023-02-09T19:35:24Z")

</div>

Two separate vectors of same length (but the lenghth can vary and is not predictable) and eliminating items in both vectors, whenever the values of those vectors are the same at identical columns. Depending on this the v…

---

## [CatViews for CUDA.jl?](https://discourse.julialang.org/t/catviews-for-cuda-jl/94304)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 12\
**Last updated:** [February 10, 2023, 6:06pm UTC](https://discourse.julialang.org/t/catviews-for-cuda-jl/94304 "2023-02-10T18:06:03Z")

</div>

Hello! I found a bit of an old package, but with a great feature I want to have so much in my code. It would let me keep current code structure and give me the flexibility I need. The package is: With the example pro…

---

## [OrdinaryDiffEq Loading Time](https://discourse.julialang.org/t/ordinarydiffeq-loading-time/94386)

<div class="topic-metadata">

**Author:** [@pranavkrishna](https://discourse.julialang.org/u/pranavkrishna)\
**Replies:** 11\
**Last updated:** [February 10, 2023, 5:58pm UTC](https://discourse.julialang.org/t/ordinarydiffeq-loading-time/94386 "2023-02-10T17:58:08Z")

</div>

I am wondering if it is usual for it to take ~30 seconds to load the OrdinaryDiffEq package. I am curious why there is so much recompilation when loading the package. Is there something I could do to reduce the load time…

---

## [Different behaviour between CairoMakie and GLMakie](https://discourse.julialang.org/t/different-behaviour-between-cairomakie-and-glmakie/94405)

<div class="topic-metadata">

**Author:** [@Maucejo](https://discourse.julialang.org/u/Maucejo)\
**Replies:** 2\
**Last updated:** [February 10, 2023, 1:22pm UTC](https://discourse.julialang.org/t/different-behaviour-between-cairomakie-and-glmakie/94405 "2023-02-10T13:22:30Z")

</div>

Hi all, I am confused since a couple of days, because GLMakie and CairoMakie have a different behavior. Here is the MWE: using CairoMakie # using GLMakie x = range(0., 2π, 100) z = sin.(x) x = range(0., 2π, 100) z = …

---

## [Find\_zero to find a solution x as a function of y?](https://discourse.julialang.org/t/find-zero-to-find-a-solution-x-as-a-function-of-y/91628)

<div class="topic-metadata">

**Author:** [@kwyyoo](https://discourse.julialang.org/u/kwyyoo)\
**Replies:** 10\
**Last updated:** [February 10, 2023, 5:45pm UTC](https://discourse.julialang.org/t/find-zero-to-find-a-solution-x-as-a-function-of-y/91628 "2023-02-10T17:45:18Z")

</div>

Hi. This is my first thread topic and question ever posting here. I have the following function and the my goal is to find a solution of x to make it zero. f(x, y) = (x^0.5 - y)/(1-x) - x^(-0.5); Can I find the soluti…

---

## [How to get upper triangular values of a \`Matrix\`?](https://discourse.julialang.org/t/how-to-get-upper-triangular-values-of-a-matrix/94391)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 2\
**Last updated:** [February 10, 2023, 3:37pm UTC](https://discourse.julialang.org/t/how-to-get-upper-triangular-values-of-a-matrix/94391 "2023-02-10T15:37:07Z")

</div>

Suppose I have a Matrix, and I only want the upper triangular values stored in a Vector: julia\> A = \[1.0 2.0 3.0; 4.0 5.0 6.0; 7.0 8.0 9.0\] 3×3 Matrix{Float64}: 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 julia\> Upper…

---

## [Elegant way to do multi-index algebra](https://discourse.julialang.org/t/elegant-way-to-do-multi-index-algebra/94370)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 4\
**Last updated:** [February 10, 2023, 2:34pm UTC](https://discourse.julialang.org/t/elegant-way-to-do-multi-index-algebra/94370 "2023-02-10T14:34:59Z")

</div>

I want to use a number to represent a multi-index. Consider i in 1:3 and j in 1:3. I want 3 to represent for (0,3), 4 for (1,1), 8 for (3,2) and so forth. This can be done by i = (num-1)÷3 + 1 and j = (num-1)%3 + 1. Thi…

---

## [Symbolic matrix exponential](https://discourse.julialang.org/t/symbolic-matrix-exponential/85435)

<div class="topic-metadata">

**Author:** [@Kaguro](https://discourse.julialang.org/u/Kaguro)\
**Replies:** 9\
**Last updated:** [February 10, 2023, 1:45pm UTC](https://discourse.julialang.org/t/symbolic-matrix-exponential/85435 "2023-02-10T13:45:23Z")

</div>

Hello All! I am fairly new to Julia. I want to find the matrix exponential of a symbolic matrix. How to do this? When I use the Symbolics and LinearAlgebra packages together, it doesn’t work: using Symbolics using Lin…

---

## [How to obtain the name of a constant given it's value?](https://discourse.julialang.org/t/how-to-obtain-the-name-of-a-constant-given-its-value/94402)

<div class="topic-metadata">

**Author:** [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Replies:** 4\
**Last updated:** [February 10, 2023, 10:46am UTC](https://discourse.julialang.org/t/how-to-obtain-the-name-of-a-constant-given-its-value/94402 "2023-02-10T10:46:59Z")

</div>

Suppose we have defined some const MY\_CONST\_NAME = 1. Then we have some function x = returnSomeNumber() which returns 1. Is it possible to print MY\_CONST\_NAME instead of 1 given the value of x without using, e.g., an ad…

---

## [Using large NTuples makes Julia hang](https://discourse.julialang.org/t/using-large-ntuples-makes-julia-hang/78900)

<div class="topic-metadata">

**Author:** [@Maurizio\_Tomasi](https://discourse.julialang.org/u/Maurizio_Tomasi)\
**Replies:** 23\
**Last updated:** [February 10, 2023, 10:40am UTC](https://discourse.julialang.org/t/using-large-ntuples-makes-julia-hang/78900 "2023-02-10T10:40:10Z")

</div>

Julia 1.7.2 on Linux x86\_64 seems to hang when instantiating structures containing large NTuple types, as the following code shows: struct Foo id:: UInt64 tag::NTuple{32, UInt8} start\_comment::NTuple{4096, U…

---

## [Fast string comparisons for strings of fixed length](https://discourse.julialang.org/t/fast-string-comparisons-for-strings-of-fixed-length/94378)

<div class="topic-metadata">

**Author:** [@davidbp](https://discourse.julialang.org/u/davidbp)\
**Replies:** 3\
**Last updated:** [February 10, 2023, 10:23am UTC](https://discourse.julialang.org/t/fast-string-comparisons-for-strings-of-fixed-length/94378 "2023-02-10T10:23:45Z")

</div>

I want to leave here an interesting benchmark and see if someone comes with a new approach that provides faster results. The problem is: Given two arrays list and blocklist, find which elements in list also belong to b…

---

## [Computation of the expected value of a multidimensional array providing PMF on each dimension](https://discourse.julialang.org/t/computation-of-the-expected-value-of-a-multidimensional-array-providing-pmf-on-each-dimension/94404)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 0\
**Last updated:** [February 10, 2023, 10:20am UTC](https://discourse.julialang.org/t/computation-of-the-expected-value-of-a-multidimensional-array-providing-pmf-on-each-dimension/94404 "2023-02-10T10:20:26Z")

</div>

Isn’t there something smarter already in the Julia standard lib to compute the expected value of a multidimensional tensor given a vector of PMFs than the following code ? julia\> function EV(v,p) # v is a multidimension…

---

## [Getting OpticSim.jl to work](https://discourse.julialang.org/t/getting-opticsim-jl-to-work/93982)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 8\
**Last updated:** [February 10, 2023, 7:01am UTC](https://discourse.julialang.org/t/getting-opticsim-jl-to-work/93982 "2023-02-10T07:01:25Z")

</div>

The documentation for OpticSim.jl says that I should “Run this example to check that everything installed properly”. The example produces the following for me: julia\> using OpticSim julia\> Vis.draw(SphericalLens(OpticS…

---

## [Why is it that Arrays can't be modified using nested index](https://discourse.julialang.org/t/why-is-it-that-arrays-cant-be-modified-using-nested-index/93889)

<div class="topic-metadata">

**Author:** [@alex-s-gardner](https://discourse.julialang.org/u/alex-s-gardner)\
**Replies:** 18\
**Last updated:** [February 10, 2023, 5:10am UTC](https://discourse.julialang.org/t/why-is-it-that-arrays-cant-be-modified-using-nested-index/93889 "2023-02-10T05:10:08Z")

</div>

In this expression A = ones(3,3); # this works A\[1,1\] = 2; julia\> A 3×3 Matrix{Float64}: 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 # but this does not A\[:,1\]\[1\] = 3; julia\> A 3×3 Matrix{Float64}: 2.0 1.0 1.0 1…

---

## [InitError(mod=:micromamba\_jll](https://discourse.julialang.org/t/initerror-mod-micromamba-jll/94377)

<div class="topic-metadata">

**Author:** [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Replies:** 7\
**Last updated:** [February 10, 2023, 1:27am UTC](https://discourse.julialang.org/t/initerror-mod-micromamba-jll/94377 "2023-02-10T01:27:06Z")

</div>

I fail to run the application MyApp.exe compiled from the minimal example of the package PackageCompiler The error message can be found here: # InitError(mod=:micromamba\_jll … Any ideas? - Is this a current situation …

---

## [Multiple tests and error checking at the time of creating a struct with a many properties](https://discourse.julialang.org/t/multiple-tests-and-error-checking-at-the-time-of-creating-a-struct-with-a-many-properties/94317)

<div class="topic-metadata">

**Author:** [@saumil-sh](https://discourse.julialang.org/u/saumil-sh)\
**Replies:** 10\
**Last updated:** [February 9, 2023, 11:10pm UTC](https://discourse.julialang.org/t/multiple-tests-and-error-checking-at-the-time-of-creating-a-struct-with-a-many-properties/94317 "2023-02-09T23:10:54Z")

</div>

I am new to Julia and object-oriented programming. I am used to the following practice function compare\_sizes(x,y) length(x) == length(y) ? "good to go" : error(DimensionMismatch) end Now, in object-oriented progra…

---

## [Implement getindex for array indexing and range indexing](https://discourse.julialang.org/t/implement-getindex-for-array-indexing-and-range-indexing/94369)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 4\
**Last updated:** [February 9, 2023, 10:17pm UTC](https://discourse.julialang.org/t/implement-getindex-for-array-indexing-and-range-indexing/94369 "2023-02-09T22:17:38Z")

</div>

I have a struct which should behave like a matrix. I want to have all the standard indexing methods julia has, like A\[:, j\], A\[1:3, j\], A\[\[1,3,4\], j\] and so on. Currently I have the following (simplified) function Base…

---

## [CairoMakie: UndefVarError: Axis not defined](https://discourse.julialang.org/t/cairomakie-undefvarerror-axis-not-defined/94367)

<div class="topic-metadata">

**Author:** [@aquarelleX332](https://discourse.julialang.org/u/aquarelleX332)\
**Replies:** 3\
**Last updated:** [February 9, 2023, 9:06pm UTC](https://discourse.julialang.org/t/cairomakie-undefvarerror-axis-not-defined/94367 "2023-02-09T21:06:49Z")

</div>

Hello dear all, Julia-1.8.5 Makie v0.19.2 CairoMakie v0.10.2 I am trying to learn the basics of Makie according to the basic tutorial. After installation: julia\> using CairoMakie julia\> f = Figure(resolution = (40…

---

## [Bug/unexpected behavior when extending Base.any with new type](https://discourse.julialang.org/t/bug-unexpected-behavior-when-extending-base-any-with-new-type/94359)

<div class="topic-metadata">

**Author:** [@brunbjerg](https://discourse.julialang.org/u/brunbjerg)\
**Replies:** 4\
**Last updated:** [February 9, 2023, 7:40pm UTC](https://discourse.julialang.org/t/bug-unexpected-behavior-when-extending-base-any-with-new-type/94359 "2023-02-09T19:40:26Z")

</div>

I have extended the any function as shown in the example below: function Base.any(array::Matrix{Real}) checker = zeros(Bool, size(array)\[1\]) for i in axes(array, 1) for j in axes(array, 2) i…

---

## [What does \`Base.@ccallable\` do?](https://discourse.julialang.org/t/what-does-base-ccallable-do/71194)

<div class="topic-metadata">

**Author:** [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Replies:** 2\
**Last updated:** [February 9, 2023, 7:06pm UTC](https://discourse.julialang.org/t/what-does-base-ccallable-do/71194 "2023-02-09T19:06:12Z")

</div>

It’s mentioned in the docs for PackageCompiler (Apps · PackageCompiler) but is not itself documented.

---

## [Improving the speed of large population simulations in DifferentialEquations.jl](https://discourse.julialang.org/t/improving-the-speed-of-large-population-simulations-in-differentialequations-jl/93109)

<div class="topic-metadata">

**Author:** [@freddie090](https://discourse.julialang.org/u/freddie090)\
**Replies:** 10\
**Last updated:** [February 9, 2023, 6:48pm UTC](https://discourse.julialang.org/t/improving-the-speed-of-large-population-simulations-in-differentialequations-jl/93109 "2023-02-09T18:48:23Z")

</div>

Hi, Apologies if this isn’t the correct forum for this style of question, but I think it could be viewed as a performance problem. Sensitive/Resistant Birth Death Simulation I have a birth-death simulation I am runnin…

---

## [In-place inverse permutation](https://discourse.julialang.org/t/in-place-inverse-permutation/94368)

<div class="topic-metadata">

**Author:** [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Replies:** 1\
**Last updated:** [February 9, 2023, 6:16pm UTC](https://discourse.julialang.org/t/in-place-inverse-permutation/94368 "2023-02-09T18:16:46Z")

</div>

Is there a reason that there is not an in-place equivalent of sortperm!, i.e., “invperm!”? One current (v1.8.3) approach would be to call invpermute!(v, sig) for permutation sig, but the docs say that for v with many el…

---

## [Tying a function to an array when I get the value of the array](https://discourse.julialang.org/t/tying-a-function-to-an-array-when-i-get-the-value-of-the-array/94354)

<div class="topic-metadata">

**Author:** [@LolianSh](https://discourse.julialang.org/u/LolianSh)\
**Replies:** 4\
**Last updated:** [February 9, 2023, 6:00pm UTC](https://discourse.julialang.org/t/tying-a-function-to-an-array-when-i-get-the-value-of-the-array/94354 "2023-02-09T18:00:28Z")

</div>

Hi everyone, I have question. Maybe someone has encountered this before and can help me out. I would like to do the following: searchsortedfirst(ntoh.(v), x) Assuming v is a memory mapped vector on disk. Using ntoh.(…

---

## [How to get parent module of a submodule](https://discourse.julialang.org/t/how-to-get-parent-module-of-a-submodule/94364)

<div class="topic-metadata">

**Author:** [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Replies:** 3\
**Last updated:** [February 9, 2023, 5:31pm UTC](https://discourse.julialang.org/t/how-to-get-parent-module-of-a-submodule/94364 "2023-02-09T17:31:55Z")

</div>

Probably it is something simple and obvious, but I can’t find the solution. Does anyone knows how to get parent module of a submodule? By parent module I mean that if we have submodule Foo.Bar, then it’s parent module is…

---

## [How to compare two vectors whose elements are equal but their types are not the same?](https://discourse.julialang.org/t/how-to-compare-two-vectors-whose-elements-are-equal-but-their-types-are-not-the-same/94309)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 5\
**Last updated:** [February 9, 2023, 3:53pm UTC](https://discourse.julialang.org/t/how-to-compare-two-vectors-whose-elements-are-equal-but-their-types-are-not-the-same/94309 "2023-02-09T15:53:30Z")

</div>

Suppose we have two types, A and B, which are just two wrapper types of Vectors: struct A{T} \<: AbstractVector{T} data::Vector{T} end struct B{T} \<: AbstractVector{T} data::Vector{T} end Base.size(x::Union{A,B}) …

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

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