# General Usage

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

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

**Page:** 371

---

## [Using ccall with pointers in signature](https://discourse.julialang.org/t/using-ccall-with-pointers-in-signature/90124)

<div class="topic-metadata">

**Author:** [@nvenkov1](https://discourse.julialang.org/u/nvenkov1)\
**Replies:** 4\
**Last updated:** [November 11, 2022, 4:15pm UTC](https://discourse.julialang.org/t/using-ccall-with-pointers-in-signature/90124 "2022-11-11T16:15:39Z")

</div>

I have a C function with signature double \*fwht(double \*a, int n). I have compiled the function as part of a shared library and I try to call it with ccall from Julia with ccall((:fwht, "./libmean.so"), Vector{Float64},…

---

## [Differences in Two DataFrames](https://discourse.julialang.org/t/differences-in-two-dataframes/90068)

<div class="topic-metadata">

**Author:** [@r0b0ty](https://discourse.julialang.org/u/r0b0ty)\
**Replies:** 5\
**Last updated:** [November 11, 2022, 2:34pm UTC](https://discourse.julialang.org/t/differences-in-two-dataframes/90068 "2022-11-11T14:34:21Z")

</div>

Given two DataFrames of different lengths, and different parameter names… julia\> dfA = DataFrame(:Parameter =\> \["size", "weight", "color", "smell"\], :Value =\> \["small", "120", "red", "none"\]) 4×2 DataFrame Row │…

---

## [Getting Error while using lambdify](https://discourse.julialang.org/t/getting-error-while-using-lambdify/89956)

<div class="topic-metadata">

**Author:** [@Starpower\_Power](https://discourse.julialang.org/u/Starpower_Power)\
**Replies:** 4\
**Last updated:** [November 11, 2022, 1:17pm UTC](https://discourse.julialang.org/t/getting-error-while-using-lambdify/89956 "2022-11-11T13:17:05Z")

</div>

---

## [Difficulty using ccall](https://discourse.julialang.org/t/difficulty-using-ccall/90065)

<div class="topic-metadata">

**Author:** [@nvenkov1](https://discourse.julialang.org/u/nvenkov1)\
**Replies:** 11\
**Last updated:** [November 11, 2022, 1:15pm UTC](https://discourse.julialang.org/t/difficulty-using-ccall/90065 "2022-11-11T13:15:30Z")

</div>

I have a shared library file called /home/nxf93431/work/test/julia-gram-schmidt/libmean.so which contains a C function double mean(double a, double b) I try to run in Julia with ccall. I do the following: using Libdl p…

---

## [Break statement in foldscuda/floops is giving error](https://discourse.julialang.org/t/break-statement-in-foldscuda-floops-is-giving-error/89864)

<div class="topic-metadata">

**Author:** [@nethaji8](https://discourse.julialang.org/u/nethaji8)\
**Replies:** 4\
**Last updated:** [November 11, 2022, 10:23am UTC](https://discourse.julialang.org/t/break-statement-in-foldscuda-floops-is-giving-error/89864 "2022-11-11T10:23:15Z")

</div>

Hi everyone, I am trying to use Floops, and FoldsCuda library as an alternative to OpenACC in Cuda c++, and Fortran in Julia. Consider the following code using Random, CUDA, FLoops, Test, FoldsCUDA function main() …

---

## [Package dependency tree?](https://discourse.julialang.org/t/package-dependency-tree/90092)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 1\
**Last updated:** [November 11, 2022, 2:58am UTC](https://discourse.julialang.org/t/package-dependency-tree/90092 "2022-11-11T02:58:52Z")

</div>

I was dismayed today to find when adding my own package to a project, a whole bag of other packages were dragged in, including Makie. Which then compiled for minutes… How do I find which package caused this dependency c…

---

## [Union all Types](https://discourse.julialang.org/t/union-all-types/90087)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 2\
**Last updated:** [November 11, 2022, 2:57am UTC](https://discourse.julialang.org/t/union-all-types/90087 "2022-11-11T02:57:35Z")

</div>

Pair{Symbol,Number} Would be a nice short-hand for Pair{Symbol,T} where T\<:Number is there a reason it can’t be written like this? it would be nice to write f(x::Pair{Symbol,Number}) = 1 instead of f(x::Pair{Sym…

---

## [Kwarg depending on type of another kwarg](https://discourse.julialang.org/t/kwarg-depending-on-type-of-another-kwarg/90035)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 1\
**Last updated:** [November 10, 2022, 11:38pm UTC](https://discourse.julialang.org/t/kwarg-depending-on-type-of-another-kwarg/90035 "2022-11-10T23:38:24Z")

</div>

I want to define a keyword argument that depends on the type of another keyword argument. For example, function testf(c; a::A = 0.0, b::NTuple{2, Type{A}} = (A, A)) where A end This is not possible, though: julia\> te…

---

## [Misunderstanding of the copy() function](https://discourse.julialang.org/t/misunderstanding-of-the-copy-function/90078)

<div class="topic-metadata">

**Author:** [@Zackyzz](https://discourse.julialang.org/u/Zackyzz)\
**Replies:** 1\
**Last updated:** [November 10, 2022, 10:37pm UTC](https://discourse.julialang.org/t/misunderstanding-of-the-copy-function/90078 "2022-11-10T22:37:26Z")

</div>

Hello! I come from a Lisp background and mostly when I change a parameter inside a function I prefer to have it modified only in that function. Now from what I’ve seen from the bellow code, lst actually gets modified to…

---

## [Zygote differentiation with DynamicPolynomials](https://discourse.julialang.org/t/zygote-differentiation-with-dynamicpolynomials/90064)

<div class="topic-metadata">

**Author:** [@mhar](https://discourse.julialang.org/u/mhar)\
**Replies:** 0\
**Last updated:** [November 10, 2022, 6:12pm UTC](https://discourse.julialang.org/t/zygote-differentiation-with-dynamicpolynomials/90064 "2022-11-10T18:12:47Z")

</div>

My primary question is: I want to write a custom adjoint for something that has a similar structure to the following, but I keep getting errors with my attempts. I think I am getting the types wrong. using DynamicPolyno…

---

## [Lambdify, no method matching getindex](https://discourse.julialang.org/t/lambdify-no-method-matching-getindex/90025)

<div class="topic-metadata">

**Author:** [@xyli](https://discourse.julialang.org/u/xyli)\
**Replies:** 2\
**Last updated:** [November 10, 2022, 6:03pm UTC](https://discourse.julialang.org/t/lambdify-no-method-matching-getindex/90025 "2022-11-10T18:03:49Z")

</div>

Does anyone know how to resolve the following issue of “lamdify”? julia\> using SymPy julia\> @syms x, y, z julia\> xx = zeros(Sym, 2, 1) julia\> xx\[1\] = xyz julia\> xx\[2\] = x^2 julia\> xx = xx.\*\[1,1\] julia\> fxx = lambd…

---

## [How to write Plots/Makie recipes for a module without having it precompile](https://discourse.julialang.org/t/how-to-write-plots-makie-recipes-for-a-module-without-having-it-precompile/89717)

<div class="topic-metadata">

**Author:** [@danilo-bc](https://discourse.julialang.org/u/danilo-bc)\
**Replies:** 3\
**Last updated:** [November 10, 2022, 5:33pm UTC](https://discourse.julialang.org/t/how-to-write-plots-makie-recipes-for-a-module-without-having-it-precompile/89717 "2022-11-10T17:33:54Z")

</div>

I’m trying to create a Julia modules for simple mathematical functions, but I want to separate code which calculates from code which show stuff on the screen (plot recipes). I want each mathematical domain to be in thei…

---

## [⊗ in using](https://discourse.julialang.org/t/in-using/90056)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 5\
**Last updated:** [November 10, 2022, 4:29pm UTC](https://discourse.julialang.org/t/in-using/90056 "2022-11-10T16:29:33Z")

</div>

I am trying to make using TensorCast: ⊗ work. For the above I get an LoadError: "invalid \\"using\\" statement: expected identifier". I tried various combinations of : and ()s, what’s the right way? Eg import Base: + jus…

---

## [Avoiding module \_\_init\_\_ being called multiple times](https://discourse.julialang.org/t/avoiding-module-init-being-called-multiple-times/83298)

<div class="topic-metadata">

**Author:** [@Amval](https://discourse.julialang.org/u/Amval)\
**Replies:** 3\
**Last updated:** [November 10, 2022, 4:28pm UTC](https://discourse.julialang.org/t/avoiding-module-init-being-called-multiple-times/83298 "2022-11-10T16:28:27Z")

</div>

Hello, I have been porting a web service I have to Genie. I have found the default structure very helpful to organize my project (auto-loading of libs, controller default structure, etc). I have the following problem: …

---

## [Increase the speed of For Loop in julia](https://discourse.julialang.org/t/increase-the-speed-of-for-loop-in-julia/89985)

<div class="topic-metadata">

**Author:** [@xspeng](https://discourse.julialang.org/u/xspeng)\
**Replies:** 9\
**Last updated:** [November 10, 2022, 2:36pm UTC](https://discourse.julialang.org/t/increase-the-speed-of-for-loop-in-julia/89985 "2022-11-10T14:36:30Z")

</div>

When I solve the ODEs, I try to write the 136 equations with a for loop, which makes the program more clean. However, compare with the initial program (in which I expand each equation completely), the new program needs t…

---

## [How to read data from a file in a multithreading loop](https://discourse.julialang.org/t/how-to-read-data-from-a-file-in-a-multithreading-loop/89925)

<div class="topic-metadata">

**Author:** [@NikoBiele](https://discourse.julialang.org/u/NikoBiele)\
**Replies:** 7\
**Last updated:** [November 10, 2022, 2:13pm UTC](https://discourse.julialang.org/t/how-to-read-data-from-a-file-in-a-multithreading-loop/89925 "2022-11-10T14:13:05Z")

</div>

Hi Julia community, My name is Nikolaj, I am not an expert on Julia, but I really like the syntax and speed of Julia. I am using Julia to determine the wavelength dependent absorption coefficient of CO2, based on line-…

---

## [Plotting functions of the DE solutions](https://discourse.julialang.org/t/plotting-functions-of-the-de-solutions/89837)

<div class="topic-metadata">

**Author:** [@Sh\_166](https://discourse.julialang.org/u/Sh_166)\
**Replies:** 1\
**Last updated:** [November 10, 2022, 2:08pm UTC](https://discourse.julialang.org/t/plotting-functions-of-the-de-solutions/89837 "2022-11-10T14:08:07Z")

</div>

Hi, so, I was trying to plot a function that takes the solution of a DE as it’s arguments. In particular, these are the equations I solved, and I wanted to plot something like the normal modes (linear combinations of the…

---

## [Could not reach pkg.julialang.org](https://discourse.julialang.org/t/could-not-reach-pkg-julialang-org/90048)

<div class="topic-metadata">

**Author:** [@YongHee-Kim](https://discourse.julialang.org/u/YongHee-Kim)\
**Replies:** 2\
**Last updated:** [November 10, 2022, 2:04pm UTC](https://discourse.julialang.org/t/could-not-reach-pkg-julialang-org/90048 "2022-11-10T14:04:41Z")

</div>

This has been happening to me for few months. I can manually update general registry from ./julia/registries but this is inconvenient. Does anyone having same issue as me?

---

## [How to reduce type-instability performance issues in general problem interfaces?](https://discourse.julialang.org/t/how-to-reduce-type-instability-performance-issues-in-general-problem-interfaces/90045)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 9\
**Last updated:** [November 10, 2022, 2:02pm UTC](https://discourse.julialang.org/t/how-to-reduce-type-instability-performance-issues-in-general-problem-interfaces/90045 "2022-11-10T14:02:44Z")

</div>

I am trying to write a simple interface to define and solve a specific class of problem. The problems are defined by sets of functions and sets of variables. There can be a mix of function types, and a mix of variable ty…

---

## [How to plot a function with complex values?](https://discourse.julialang.org/t/how-to-plot-a-function-with-complex-values/90026)

<div class="topic-metadata">

**Author:** [@maoc](https://discourse.julialang.org/u/maoc)\
**Replies:** 3\
**Last updated:** [November 10, 2022, 12:46pm UTC](https://discourse.julialang.org/t/how-to-plot-a-function-with-complex-values/90026 "2022-11-10T12:46:42Z")

</div>

I’d like to plot a function on the complex plane, but I’m not very familiar with complex numbers in Julia anymore. How to plot h\_z(x)= e^{i \\langle z,x \\rangle}- 1 when z is fixed? For example, z=(1,1). How to visualiz…

---

## [Impact of specifying input types on function performance, when referencing arguments from Vector{Any}](https://discourse.julialang.org/t/impact-of-specifying-input-types-on-function-performance-when-referencing-arguments-from-vector-any/89993)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 16\
**Last updated:** [November 10, 2022, 1:07pm UTC](https://discourse.julialang.org/t/impact-of-specifying-input-types-on-function-performance-when-referencing-arguments-from-vector-any/89993 "2022-11-10T13:07:58Z")

</div>

I have a performance issue I’d like to solve. I need to reference some function arguments from a Vector{Any} array. Most of the time this is incurring an expensive allocation penalty. However, when I call an explicitly t…

---

## [How to document struct fields programmatically](https://discourse.julialang.org/t/how-to-document-struct-fields-programmatically/90042)

<div class="topic-metadata">

**Author:** [@nandoconde](https://discourse.julialang.org/u/nandoconde)\
**Replies:** 0\
**Last updated:** [November 10, 2022, 10:21am UTC](https://discourse.julialang.org/t/how-to-document-struct-fields-programmatically/90042 "2022-11-10T10:21:12Z")

</div>

Is there any way to add documentation to fields in my struct programmatically (after defining the struct)? "MyStruct doc" struct MyStruct "MyStruct.a doc" a::Float64 end # This has docs for ?MyStruct.a "MyStruc…

---

## [How to see the color layers of an image in Julia](https://discourse.julialang.org/t/how-to-see-the-color-layers-of-an-image-in-julia/21513)

<div class="topic-metadata">

**Author:** [@GERSON\_EZEQUIEL\_HERN](https://discourse.julialang.org/u/GERSON_EZEQUIEL_HERN)\
**Replies:** 3\
**Last updated:** [November 10, 2022, 6:43am UTC](https://discourse.julialang.org/t/how-to-see-the-color-layers-of-an-image-in-julia/21513 "2022-11-10T06:43:38Z")

</div>

I want to see the layers of color that my image has, in this case it is toy occupying the image of the mandril, and I want to see all the layers of color that that image has. Can somebody help me?

---

## [Is there a way to pass a list of packages to \`using\` in a similar way as \`Pkg.add()\`](https://discourse.julialang.org/t/is-there-a-way-to-pass-a-list-of-packages-to-using-in-a-similar-way-as-pkg-add/90012)

<div class="topic-metadata">

**Author:** [@alex-s-gardner](https://discourse.julialang.org/u/alex-s-gardner)\
**Replies:** 8\
**Last updated:** [November 10, 2022, 6:31am UTC](https://discourse.julialang.org/t/is-there-a-way-to-pass-a-list-of-packages-to-using-in-a-similar-way-as-pkg-add/90012 "2022-11-10T06:31:51Z")

</div>

Is there a way to pass a list of packages to using in a similar way as Pkg.add() ? This works: package\_names = \["DateFormats", "Statistics"\] using Pkg Pkg.add(package\_names) but I can’t do this using(package\_names) …

---

## [Simplest way to start Julia with threading on MacOS](https://discourse.julialang.org/t/simplest-way-to-start-julia-with-threading-on-macos/90016)

<div class="topic-metadata">

**Author:** [@rasmushenningsson](https://discourse.julialang.org/u/rasmushenningsson)\
**Replies:** 4\
**Last updated:** [November 10, 2022, 4:50am UTC](https://discourse.julialang.org/t/simplest-way-to-start-julia-with-threading-on-macos/90016 "2022-11-10T04:50:51Z")

</div>

Simplest way to start Julia with threading on MacOS Hi! I have a collaborator with a Mac computer but without admin rights. Julia is installed on the computer, but not added to path. Now, I want to find the simplest …

---

## [Catch warnings](https://discourse.julialang.org/t/catch-warnings/29603)

<div class="topic-metadata">

**Author:** [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Replies:** 2\
**Last updated:** [November 9, 2022, 10:36pm UTC](https://discourse.julialang.org/t/catch-warnings/29603 "2022-11-09T22:36:46Z")

</div>

How could I catch if a block of code issues some warning? Something like try - catch for warnings. Or alternatively, how make warnings throw an error?

---

## [Is working with SubArrays of a SparseMatrix a bad idea?](https://discourse.julialang.org/t/is-working-with-subarrays-of-a-sparsematrix-a-bad-idea/90000)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 9\
**Last updated:** [November 9, 2022, 8:16pm UTC](https://discourse.julialang.org/t/is-working-with-subarrays-of-a-sparsematrix-a-bad-idea/90000 "2022-11-09T20:16:16Z")

</div>

I’ve been trying to work with views of a SparseMatrix for a while now. The goal is to avoid extra copies when you want to operate inplace on a subsection of the sparse matrix. I’ve run into enough issues that I’m startin…

---

## [Allocation and slow down when # of types involved increase (slower than C++ virtual methods)](https://discourse.julialang.org/t/allocation-and-slow-down-when-of-types-involved-increase-slower-than-c-virtual-methods/87656)

<div class="topic-metadata">

**Author:** [@jling](https://discourse.julialang.org/u/jling)\
**Replies:** 56\
**Last updated:** [November 9, 2022, 7:38pm UTC](https://discourse.julialang.org/t/allocation-and-slow-down-when-of-types-involved-increase-slower-than-c-virtual-methods/87656 "2022-11-09T19:38:33Z")

</div>

\*Happy to pay someone to spend time investigating this The context is @peremato trying to present a Julia case for detector simulation used at e.g. CERN (the LHC) and other accelerator/medical research places: https://in…

---

## [Inverting the columns of \`LinearAlgebra.QRCompactWYQ\`](https://discourse.julialang.org/t/inverting-the-columns-of-linearalgebra-qrcompactwyq/90003)

<div class="topic-metadata">

**Author:** [@brainandforce](https://discourse.julialang.org/u/brainandforce)\
**Replies:** 0\
**Last updated:** [November 9, 2022, 7:24pm UTC](https://discourse.julialang.org/t/inverting-the-columns-of-linearalgebra-qrcompactwyq/90003 "2022-11-09T19:24:53Z")

</div>

I need to perform a QR decomposition with all of the diagonal elements of R to be positive. I’d like to do this by multiplying relevant columns of Q and rows of R by -1, but the issue that comes up is that qr!() returns L…

---

## [How a program coded and compiled in Julia compares to interpreted Julia in terms of performance?](https://discourse.julialang.org/t/how-a-program-coded-and-compiled-in-julia-compares-to-interpreted-julia-in-terms-of-performance/89995)

<div class="topic-metadata">

**Author:** [@phantomcraft](https://discourse.julialang.org/u/phantomcraft)\
**Replies:** 1\
**Last updated:** [November 9, 2022, 5:47pm UTC](https://discourse.julialang.org/t/how-a-program-coded-and-compiled-in-julia-compares-to-interpreted-julia-in-terms-of-performance/89995 "2022-11-09T17:47:20Z")

</div>

I know that I can generate an executable file in Julia: Creating a binary from Julia code · PackageCompiler In this page has a timing comparison between the interpreted and compiled app. My question is: How the perfor…

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

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