# General Usage

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

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

**Page:** 129

---

## [Structs calling each other](https://discourse.julialang.org/t/structs-calling-each-other/119921)

<div class="topic-metadata">

**Author:** [@Nichola](https://discourse.julialang.org/u/Nichola)\
**Replies:** 2\
**Last updated:** [September 26, 2024, 3:29pm UTC](https://discourse.julialang.org/t/structs-calling-each-other/119921 "2024-09-26T15:29:00Z")

</div>

I would like to define two structs AB and BA and be able to convert from one representation to the other doing AB(ba) or BA(ab) where ab and ba are instances of AB and BA respectively. for example : mutable struct AB …

---

## [Most elegant way to create a vector of results if the result is an unknown type?](https://discourse.julialang.org/t/most-elegant-way-to-create-a-vector-of-results-if-the-result-is-an-unknown-type/119906)

<div class="topic-metadata">

**Author:** [@Maurizio\_Tomasi](https://discourse.julialang.org/u/Maurizio_Tomasi)\
**Replies:** 7\
**Last updated:** [September 26, 2024, 1:56pm UTC](https://discourse.julialang.org/t/most-elegant-way-to-create-a-vector-of-results-if-the-result-is-an-unknown-type/119906 "2024-09-26T13:56:55Z")

</div>

Hi all, I am developing some simulation code that can be used either to do a quick calculation or a more complete and slower algorithm. I implemented two functions that either produce a “simple” or “complex” structure; f…

---

## [FunctionWrapper allocating when called](https://discourse.julialang.org/t/functionwrapper-allocating-when-called/119854)

<div class="topic-metadata">

**Author:** [@Goncalo\_Pena](https://discourse.julialang.org/u/Goncalo_Pena)\
**Replies:** 10\
**Last updated:** [September 26, 2024, 12:52pm UTC](https://discourse.julialang.org/t/functionwrapper-allocating-when-called/119854 "2024-09-26T12:52:50Z")

</div>

I made the following test code to check some allocations going around while using FunctionWrappers on a piece of code I have. using FunctionWrappers import FunctionWrappers: FunctionWrapper using BenchmarkTools T = Flo…

---

## [How to use ccall, cconvert, and unsafe\_convert in a convenient and memory-safe way?](https://discourse.julialang.org/t/how-to-use-ccall-cconvert-and-unsafe-convert-in-a-convenient-and-memory-safe-way/41932)

<div class="topic-metadata">

**Author:** [@sloede](https://discourse.julialang.org/u/sloede)\
**Replies:** 18\
**Last updated:** [June 24, 2020, 11:50am UTC](https://discourse.julialang.org/t/how-to-use-ccall-cconvert-and-unsafe-convert-in-a-convenient-and-memory-safe-way/41932 "2020-06-24T11:50:08Z")

</div>

I am writing Julia code to conveniently interface a C library, which in turn is just an interface to a C++ library. Therefore, many times I have to store pointers to void as the C interface does not know anything about t…

---

## [Indexing symbolic array slice does not work as expected / stays unsimplified](https://discourse.julialang.org/t/indexing-symbolic-array-slice-does-not-work-as-expected-stays-unsimplified/119907)

<div class="topic-metadata">

**Author:** [@r0uv3n](https://discourse.julialang.org/u/r0uv3n)\
**Replies:** 0\
**Last updated:** [September 26, 2024, 10:12am UTC](https://discourse.julialang.org/t/indexing-symbolic-array-slice-does-not-work-as-expected-stays-unsimplified/119907 "2024-09-26T10:12:29Z")

</div>

The code julia\> using Symbolics julia\> @variables x\[1:5\] julia\> x\[2:4\]\[1\] (x\[2:4\])\[1\] seems like it should return x\[2\] instead. Am I missing something here? My use case here is that I want to do something like julia\> …

---

## [Options for simple board game GUI](https://discourse.julialang.org/t/options-for-simple-board-game-gui/119851)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 2\
**Last updated:** [September 26, 2024, 7:04am UTC](https://discourse.julialang.org/t/options-for-simple-board-game-gui/119851 "2024-09-26T07:04:50Z")

</div>

I’d like to explore ReinforcementLearning.jl and AlphaZero.jl for playing board games with AI, and I’d like to visualize the games and allow a human player to place pieces on the board. Therefore, I’d like to make an ext…

---

## [Efficient iteration with fixed size array types without \`@generated\` functions](https://discourse.julialang.org/t/efficient-iteration-with-fixed-size-array-types-without-generated-functions/119777)

<div class="topic-metadata">

**Author:** [@brainandforce](https://discourse.julialang.org/u/brainandforce)\
**Replies:** 9\
**Last updated:** [September 26, 2024, 1:54am UTC](https://discourse.julialang.org/t/efficient-iteration-with-fixed-size-array-types-without-generated-functions/119777 "2024-09-26T01:54:40Z")

</div>

My package, CliffordNumbers.jl, has a type BitIndices{Q,C\<:AbstractCliffordNumber{Q}} \<: AbstractVector{BitIndex{Q}}, whose length is the same as that of C, and that length is known at compile time. Indexing these object…

---

## [Create dynamic functions with Macro](https://discourse.julialang.org/t/create-dynamic-functions-with-macro/119824)

<div class="topic-metadata">

**Author:** [@Ronneesley](https://discourse.julialang.org/u/Ronneesley)\
**Replies:** 15\
**Last updated:** [September 26, 2024, 12:33am UTC](https://discourse.julialang.org/t/create-dynamic-functions-with-macro/119824 "2024-09-26T00:33:22Z")

</div>

Hi, I’m trying create “dynamic” functions with macro, but it isn’t working. Let-me explain: I’ve this function: function f(::Type{T}, message) where T println("Type: ", T) println("Message: ", message) end Wh…

---

## [Differing construction and conversion for subtypes of Number](https://discourse.julialang.org/t/differing-construction-and-conversion-for-subtypes-of-number/119886)

<div class="topic-metadata">

**Author:** [@brainandforce](https://discourse.julialang.org/u/brainandforce)\
**Replies:** 0\
**Last updated:** [September 26, 2024, 12:18am UTC](https://discourse.julialang.org/t/differing-construction-and-conversion-for-subtypes-of-number/119886 "2024-09-26T00:18:48Z")

</div>

After reading a few threads here, I’ve come to understand that for subtypes of Number, construction and conversion should have nearly identical behavior (with one exception: it is expected that construction always return…

---

## [GraphNeuralNetworks.jl or GeometricFlux.jl](https://discourse.julialang.org/t/graphneuralnetworks-jl-or-geometricflux-jl/119883)

<div class="topic-metadata">

**Author:** [@depasquale](https://discourse.julialang.org/u/depasquale)\
**Replies:** 1\
**Last updated:** [September 25, 2024, 8:13pm UTC](https://discourse.julialang.org/t/graphneuralnetworks-jl-or-geometricflux-jl/119883 "2024-09-25T20:13:03Z")

</div>

Hi all, In the least divisive tone possible, I was wondering if anyone could weigh in on the benefits/downsides of GraphNeuralNetworks.jl and GeometricFlux.jl. I am getting into GNNs in julia, and they seems to overlap.…

---

## [GLMakie log10 plot UI problems](https://discourse.julialang.org/t/glmakie-log10-plot-ui-problems/119870)

<div class="topic-metadata">

**Author:** [@devel-chm](https://discourse.julialang.org/u/devel-chm)\
**Replies:** 1\
**Last updated:** [September 25, 2024, 5:04pm UTC](https://discourse.julialang.org/t/glmakie-log10-plot-ui-problems/119870 "2024-09-25T17:04:09Z")

</div>

I’ve been working to get a custom GLMakie plot recipe with log scaling on the Y-axis. When I tried using DataInspector() to look at the values in the plots I find that the tooltip is either misplaced or totally not vi…

---

## [New to Julia. Reading Julia version numbers](https://discourse.julialang.org/t/new-to-julia-reading-julia-version-numbers/119835)

<div class="topic-metadata">

**Author:** [@pogikano](https://discourse.julialang.org/u/pogikano)\
**Replies:** 7\
**Last updated:** [September 25, 2024, 1:28pm UTC](https://discourse.julialang.org/t/new-to-julia-reading-julia-version-numbers/119835 "2024-09-25T13:28:52Z")

</div>

I have Julia version 1.10.5. I want to use the correct version of the documentation. How do I translate that into the documentation version numbering, e.g. v5.10 etc.?

---

## [Block Diagonal Factorization Performance](https://discourse.julialang.org/t/block-diagonal-factorization-performance/112294)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 1\
**Last updated:** [September 25, 2024, 1:28pm UTC](https://discourse.julialang.org/t/block-diagonal-factorization-performance/112294 "2024-09-25T13:28:08Z")

</div>

I’m looking to leverage the speedup that is possible by exploiting block diagonal structures during matrix factorization. Since I’m relying on existing code and inherent multiple dispatch, I need the solution to 1) use a…

---

## [Linear solve slower with Banded Matrix](https://discourse.julialang.org/t/linear-solve-slower-with-banded-matrix/119840)

<div class="topic-metadata">

**Author:** [@RobertGregg](https://discourse.julialang.org/u/RobertGregg)\
**Replies:** 8\
**Last updated:** [September 25, 2024, 12:08pm UTC](https://discourse.julialang.org/t/linear-solve-slower-with-banded-matrix/119840 "2024-09-25T12:08:07Z")

</div>

I was trying to speed up a linear solve (Ax=b) where my A matrix is banded. Compared to just using a sparse matrix, the banded matrix took about twice as long. using Random, SparseArrays, LinearAlgebra using BenchmarkTo…

---

## [Warning when using NonlinearSolve.jl with LinearSolve.jl and MINRES](https://discourse.julialang.org/t/warning-when-using-nonlinearsolve-jl-with-linearsolve-jl-and-minres/119781)

<div class="topic-metadata">

**Author:** [@mpf01](https://discourse.julialang.org/u/mpf01)\
**Replies:** 8\
**Last updated:** [September 25, 2024, 12:04pm UTC](https://discourse.julialang.org/t/warning-when-using-nonlinearsolve-jl-with-linearsolve-jl-and-minres/119781 "2024-09-25T12:04:21Z")

</div>

I am experimenting with NonlinearSolve.jl to solve a nonlinear system of equations with a symmetric indefinite Jacobian. I am specifically interested in using MINRES to solve this system. In my code, I’ve not specified a…

---

## [Soft scopes & globals in \`@testitem\`s](https://discourse.julialang.org/t/soft-scopes-globals-in-testitem-s/119338)

<div class="topic-metadata">

**Author:** [@Ken\_Williams](https://discourse.julialang.org/u/Ken_Williams)\
**Replies:** 7\
**Last updated:** [September 25, 2024, 11:07am UTC](https://discourse.julialang.org/t/soft-scopes-globals-in-testitem-s/119338 "2024-09-25T11:07:54Z")

</div>

I just encountered the problem discussed in Best solution to Julia's soft scope problem? , but in the context of unit tests. Specifically, in code like this: @testitem "foo" begin A = 0 for i in 1:10 A …

---

## [Gradient-based adaptative sampling in NeuralPDE](https://discourse.julialang.org/t/gradient-based-adaptative-sampling-in-neuralpde/119852)

<div class="topic-metadata">

**Author:** [@gradureau](https://discourse.julialang.org/u/gradureau)\
**Replies:** 1\
**Last updated:** [September 25, 2024, 10:15am UTC](https://discourse.julialang.org/t/gradient-based-adaptative-sampling-in-neuralpde/119852 "2024-09-25T10:15:53Z")

</div>

Hey everyone, I am testing NeuralPDE to simulate hydrodynamic shocks and I would like to try the residual/gradient adaptative sampling of data, as described in the article in the following link : Physics-informed neural…

---

## [Is there a strong case that Julia is a more composable language?](https://discourse.julialang.org/t/is-there-a-strong-case-that-julia-is-a-more-composable-language/118554)

<div class="topic-metadata">

**Author:** [@alex-s-gardner](https://discourse.julialang.org/u/alex-s-gardner)\
**Replies:** 25\
**Last updated:** [September 25, 2024, 8:13am UTC](https://discourse.julialang.org/t/is-there-a-strong-case-that-julia-is-a-more-composable-language/118554 "2024-09-25T08:13:49Z")

</div>

Is there a strong argument for why Julia inherently provides a more composable eco system relative to python and other major science ML languages? Wanting to know for grant application to support development (by others). …

---

## [How to create a wrapper package](https://discourse.julialang.org/t/how-to-create-a-wrapper-package/119605)

<div class="topic-metadata">

**Author:** [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Replies:** 5\
**Last updated:** [September 25, 2024, 7:56am UTC](https://discourse.julialang.org/t/how-to-create-a-wrapper-package/119605 "2024-09-25T07:56:48Z")

</div>

I’m interested in using HJSON but it’s quite annoying to run hjson every time and create a json file that I can then read with JSON3. How would I go about creating a HJSON.jl such that I can do the conversion inside juli…

---

## [Integrating Plots into a package](https://discourse.julialang.org/t/integrating-plots-into-a-package/119599)

<div class="topic-metadata">

**Author:** [@tduretz](https://discourse.julialang.org/u/tduretz)\
**Replies:** 8\
**Last updated:** [September 25, 2024, 6:51am UTC](https://discourse.julialang.org/t/integrating-plots-into-a-package/119599 "2024-09-25T06:51:13Z")

</div>

Hi everyone, I recently started with the development of ExactFieldSolutions. The package aims at providing full-field exact solutions for various PDEs, which can then be used for verifying the accuracy of numerical so…

---

## [Implementing inexact Newton solves in NonlinearSolve.jl](https://discourse.julialang.org/t/implementing-inexact-newton-solves-in-nonlinearsolve-jl/119844)

<div class="topic-metadata">

**Author:** [@mpf01](https://discourse.julialang.org/u/mpf01)\
**Replies:** 2\
**Last updated:** [September 25, 2024, 5:55am UTC](https://discourse.julialang.org/t/implementing-inexact-newton-solves-in-nonlinearsolve-jl/119844 "2024-09-25T05:55:59Z")

</div>

I’d like to implement inexact Newton solves using NonlinearSolve.jl. The output from this code snippet (shown below) suggests that, by default, each Newton equation is solved to a fixed accuracy. nlcache = init( pro…

---

## [Does length(itr) need to be invariant? (stateful iterator)](https://discourse.julialang.org/t/does-length-itr-need-to-be-invariant-stateful-iterator/118170)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 4\
**Last updated:** [September 24, 2024, 8:49pm UTC](https://discourse.julialang.org/t/does-length-itr-need-to-be-invariant-stateful-iterator/118170 "2024-09-24T20:49:54Z")

</div>

I have a calculation that tracks a large state for a cohort of economic agents that have a finite lifetime. A certain summary statistic is implemented with the iteration protocol. If you imagine c below to be something …

---

## [Optimizing sums of products (dot products)](https://discourse.julialang.org/t/optimizing-sums-of-products-dot-products/119515)

<div class="topic-metadata">

**Author:** [@s-baumann](https://discourse.julialang.org/u/s-baumann)\
**Replies:** 17\
**Last updated:** [September 24, 2024, 7:40pm UTC](https://discourse.julialang.org/t/optimizing-sums-of-products-dot-products/119515 "2024-09-24T19:40:11Z")

</div>

Is there a way to avoid the intermediate allocation for a sumproduct scenario? In the following case I can redo it with a for loop which improves the memory allocation but causes it to take longer to execute (the differ…

---

## [How to create permutation of named tuple values](https://discourse.julialang.org/t/how-to-create-permutation-of-named-tuple-values/119821)

<div class="topic-metadata">

**Author:** [@alex-s-gardner](https://discourse.julialang.org/u/alex-s-gardner)\
**Replies:** 2\
**Last updated:** [September 24, 2024, 6:17pm UTC](https://discourse.julialang.org/t/how-to-create-permutation-of-named-tuple-values/119821 "2024-09-24T18:17:12Z")

</div>

how can I write a generic function to generate permutations of arbitrary named tuple values this is what I currently do catagory0 = \[1,3,4\] letter0 = \["a", "b", "c"\] score0 = \[1.1, 4.\] thing0 = \["hat", "c…

---

## [Interactive plucked string simulator](https://discourse.julialang.org/t/interactive-plucked-string-simulator/119747)

<div class="topic-metadata">

**Author:** [@LeePhillips](https://discourse.julialang.org/u/LeePhillips)\
**Replies:** 3\
**Last updated:** [September 24, 2024, 3:06pm UTC](https://discourse.julialang.org/t/interactive-plucked-string-simulator/119747 "2024-09-24T15:06:47Z")

</div>

I wanted to experiment with using Julia as a back end for an interactive web thing, communicating over websockets. The result is at The Plucked String. I found that combining HTMX on the front end with the HTTP.jl webso…

---

## [How to call PythonCall.jl behind a julia HTTP webserver?](https://discourse.julialang.org/t/how-to-call-pythoncall-jl-behind-a-julia-http-webserver/119563)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 2\
**Last updated:** [September 24, 2024, 2:09pm UTC](https://discourse.julialang.org/t/how-to-call-pythoncall-jl-behind-a-julia-http-webserver/119563 "2024-09-24T14:09:21Z")

</div>

Hi there, I am wondering how I could use langchain from Python as part of a webserver. I am running into segmenation faults certainly due to multithreading. Does someone know a way whether the new @unlock and @lock are …

---

## [Flux slows down by 10x when moving from local system to high performance cluster](https://discourse.julialang.org/t/flux-slows-down-by-10x-when-moving-from-local-system-to-high-performance-cluster/119753)

<div class="topic-metadata">

**Author:** [@SGHoekstra](https://discourse.julialang.org/u/SGHoekstra)\
**Replies:** 10\
**Last updated:** [September 24, 2024, 12:15pm UTC](https://discourse.julialang.org/t/flux-slows-down-by-10x-when-moving-from-local-system-to-high-performance-cluster/119753 "2024-09-24T12:15:38Z")

</div>

Hi everyone, I am using Flux to solve a nonstandard optimisation problem with custom loss. The solution is part a of a larger simulation which I run many times (100,000+) so speed is key. When I try to run my script o…

---

## [JSON.jl Float64 serialization (suppress scientific notation)](https://discourse.julialang.org/t/json-jl-float64-serialization-suppress-scientific-notation/119775)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 0\
**Last updated:** [September 23, 2024, 9:04pm UTC](https://discourse.julialang.org/t/json-jl-float64-serialization-suppress-scientific-notation/119775 "2024-09-23T21:04:35Z")

</div>

I am having a hard time with JSON.jl. I want to serialize large Float64 instances without scientific notation and the only way I was able to get at least the rounding working results in a string, instead of a float value…

---

## [Efficiently creating and updating a struct of SVectors](https://discourse.julialang.org/t/efficiently-creating-and-updating-a-struct-of-svectors/119697)

<div class="topic-metadata">

**Author:** [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Replies:** 10\
**Last updated:** [September 23, 2024, 7:58pm UTC](https://discourse.julialang.org/t/efficiently-creating-and-updating-a-struct-of-svectors/119697 "2024-09-23T19:58:17Z")

</div>

Part A I’m reading some data in from a file then storing it in a struct looking something like this: # "Big" struct of SVectors @with\_kw struct BigStruct{N} A :: SVector{N, Int16} B :: SVector{N, Int16} C :…

---

## [Sinc function - and sinc neural networks - and function approximation for the former](https://discourse.julialang.org/t/sinc-function-and-sinc-neural-networks-and-function-approximation-for-the-former/46483)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 20\
**Last updated:** [September 22, 2024, 10:00pm UTC](https://discourse.julialang.org/t/sinc-function-and-sinc-neural-networks-and-function-approximation-for-the-former/46483 "2024-09-22T22:00:30Z")

</div>

First, has anyone reimplemented Sinc neural networks in Julia? Those are for speaker recognition, state-of-the-art I believe, and should similarly help for speech recognition, and other audio work. So far, I’m just look…

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

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