# General Usage

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

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

**Page:** 465

---

## [Apply LinearTransformation to a Rectangle](https://discourse.julialang.org/t/apply-lineartransformation-to-a-rectangle/78926)

<div class="topic-metadata">

**Author:** [@vshesh](https://discourse.julialang.org/u/vshesh)\
**Replies:** 1\
**Last updated:** [April 3, 2022, 8:28pm UTC](https://discourse.julialang.org/t/apply-lineartransformation-to-a-rectangle/78926 "2022-04-03T20:28:55Z")

</div>

I have represented a box as a 4 col x 2 row matrix something like bbox = \[0 0 ; 50 0; 50 100; 0 100\] I have a few of these boxes and I want to rotate them by a certain angle. I create a LinearMap(RotMatrix(deg2rad(an…

---

## [Operations on type paramteres](https://discourse.julialang.org/t/operations-on-type-paramteres/78954)

<div class="topic-metadata">

**Author:** [@Mohamed\_AbdElrahman](https://discourse.julialang.org/u/Mohamed_AbdElrahman)\
**Replies:** 2\
**Last updated:** [April 3, 2022, 7:46pm UTC](https://discourse.julialang.org/t/operations-on-type-paramteres/78954 "2022-04-03T19:46:16Z")

</div>

Is there is an easy way to do something like this struct TensorField{T,ND,NC} \<: AbstractArray{T,ND+NC} end I need to define a scaler/vector/tensor field in 1D/2D/3D and I don’t want to define a type for each dimension…

---

## [Performance difference among three CUDA kernels with same results](https://discourse.julialang.org/t/performance-difference-among-three-cuda-kernels-with-same-results/78923)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 8\
**Last updated:** [April 3, 2022, 3:23pm UTC](https://discourse.julialang.org/t/performance-difference-among-three-cuda-kernels-with-same-results/78923 "2022-04-03T15:23:41Z")

</div>

I wrote a small test program to learn a bit more of CUDA.jl. I find it hard to understand why the test3! function is so much slower than test1! and test2!, especially because this is the way one would write a CUDA kernel…

---

## [Where is sparse ldlt?](https://discourse.julialang.org/t/where-is-sparse-ldlt/78929)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 2\
**Last updated:** [April 3, 2022, 1:18pm UTC](https://discourse.julialang.org/t/where-is-sparse-ldlt/78929 "2022-04-03T13:18:55Z")

</div>

The manual says it is in “CHOLMOD library from SuiteSparse” ( Linear Algebra · The Julia Language). I cannot find it there: julia\> SuiteSparse.CHOLMOD. …

---

## [Extending Base.\_searchindex to "findall"?](https://discourse.julialang.org/t/extending-base-searchindex-to-findall/78938)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 1\
**Last updated:** [April 3, 2022, 10:47am UTC](https://discourse.julialang.org/t/extending-base-searchindex-to-findall/78938 "2022-04-03T10:47:41Z")

</div>

Hello! I have a Vector{UInt8}, in which I want to find all occurences of “Lorem”. (Text from https://www.lipsum.com/) TextToSearch = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem …

---

## [Is there a unified API for loading/saving JSON, YAML, and TOML files?](https://discourse.julialang.org/t/is-there-a-unified-api-for-loading-saving-json-yaml-and-toml-files/78934)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 0\
**Last updated:** [April 3, 2022, 9:09am UTC](https://discourse.julialang.org/t/is-there-a-unified-api-for-loading-saving-json-yaml-and-toml-files/78934 "2022-04-03T09:09:28Z")

</div>

I wonder if there exists a unified API for reading/writing JSON, YAML, and TOML files. Currently, I am doing it by myself. I am treating them as configuration files to store my calculations settings. But it would be nice…

---

## [Basic expression manipulation with Symbolics.jl](https://discourse.julialang.org/t/basic-expression-manipulation-with-symbolics-jl/77799)

<div class="topic-metadata">

**Author:** [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Replies:** 2\
**Last updated:** [April 3, 2022, 7:10am UTC](https://discourse.julialang.org/t/basic-expression-manipulation-with-symbolics-jl/77799 "2022-04-03T07:10:46Z")

</div>

Hi everyone, I’m trying out a basic exercise which consists in generating the heat transfer equation (1D diffusion) by substitution the expressions of heat and heat flux in a balance equation, assuming constant coeffici…

---

## [Is it necessary for sleep to allocate?](https://discourse.julialang.org/t/is-it-necessary-for-sleep-to-allocate/77795)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 5\
**Last updated:** [April 2, 2022, 8:39pm UTC](https://discourse.julialang.org/t/is-it-necessary-for-sleep-to-allocate/77795 "2022-04-02T20:39:30Z")

</div>

I was optimizing a complex block of multithreaded code and discovered that sleep was allocating. julia\> @btime sleep(0) 1.720 μs (5 allocations: 144 bytes) I was pretty surprised, so checked the source which is basic…

---

## [Maintaining a fixed size "top N" values list](https://discourse.julialang.org/t/maintaining-a-fixed-size-top-n-values-list/78868)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 14\
**Last updated:** [April 2, 2022, 3:55pm UTC](https://discourse.julialang.org/t/maintaining-a-fixed-size-top-n-values-list/78868 "2022-04-02T15:55:50Z")

</div>

My high level need: loop through lots of entries and keep track of the top nth value so I can continue filtering out anything lower than the nth highest value. My assumption is that I would need to store the n top value…

---

## [Check if a value is rooted by the Garbage Collector (GC)](https://discourse.julialang.org/t/check-if-a-value-is-rooted-by-the-garbage-collector-gc/78887)

<div class="topic-metadata">

**Author:** [@Clemapfel](https://discourse.julialang.org/u/Clemapfel)\
**Replies:** 5\
**Last updated:** [April 2, 2022, 2:20pm UTC](https://discourse.julialang.org/t/check-if-a-value-is-rooted-by-the-garbage-collector-gc/78887 "2022-04-02T14:20:28Z")

</div>

Given a C-pointer jl\_value\_t\*, I would like to check whether the GC currently has a root to it. With root, I mean that the memory is marked such that it cannot be released when the gc starts its sweeping process. I’m pr…

---

## [Function array performance](https://discourse.julialang.org/t/function-array-performance/78889)

<div class="topic-metadata">

**Author:** [@smith-isaac](https://discourse.julialang.org/u/smith-isaac)\
**Replies:** 5\
**Last updated:** [April 2, 2022, 2:05pm UTC](https://discourse.julialang.org/t/function-array-performance/78889 "2022-04-02T14:05:26Z")

</div>

I have an array of functions that each return a float, and so I am trying to assign the results of those functions to an array. So I had something like this results = similar(f\_arr, Float64) results .= \[f(a, b, c) for f…

---

## [Can I input an invalid string into a variable?](https://discourse.julialang.org/t/can-i-input-an-invalid-string-into-a-variable/78769)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 15\
**Last updated:** [April 2, 2022, 7:11am UTC](https://discourse.julialang.org/t/can-i-input-an-invalid-string-into-a-variable/78769 "2022-04-02T07:11:14Z")

</div>

Hi! Suppose I have string such as: Part\_\\d{4} Putting it into a variable will give: ERROR: syntax: invalid escape sequence But if instead do: Variable = r"Part\_\\d{4}" Which works, which is great. But what if I wan…

---

## [Converts the given string into code with metaprogramming](https://discourse.julialang.org/t/converts-the-given-string-into-code-with-metaprogramming/78819)

<div class="topic-metadata">

**Author:** [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Replies:** 6\
**Last updated:** [April 2, 2022, 1:40am UTC](https://discourse.julialang.org/t/converts-the-given-string-into-code-with-metaprogramming/78819 "2022-04-02T01:40:55Z")

</div>

When I get a string s=“x^2+1” (It can only be a string), then how do I create a function f(x)=x^2+1. I tried the following with metaprogramming, but it didn’t work julia\> s="x^2+1" "x^2+1" julia\> f(x)=eval(Meta.parse(s…

---

## [How to build functions from symbolic expressions with symbolics.jl](https://discourse.julialang.org/t/how-to-build-functions-from-symbolic-expressions-with-symbolics-jl/78879)

<div class="topic-metadata">

**Author:** [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Replies:** 3\
**Last updated:** [April 2, 2022, 1:38am UTC](https://discourse.julialang.org/t/how-to-build-functions-from-symbolic-expressions-with-symbolics-jl/78879 "2022-04-02T01:38:14Z")

</div>

I want to build functions from symbolic expressions with symbolics.jl. I tried the following according to the documentation instructions. using Symbolics @variables x p=(1+x)^2 f\_expr=build\_function(p,x) f=eval(f\_expr)…

---

## [Current behavior of fill and the like..?](https://discourse.julialang.org/t/current-behavior-of-fill-and-the-like/78888)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 17\
**Last updated:** [April 2, 2022, 1:30am UTC](https://discourse.julialang.org/t/current-behavior-of-fill-and-the-like/78888 "2022-04-02T01:30:04Z")

</div>

fill is very useful for creating arrays having the same vaule at all locations. However, if this vaule is a mutable object, fill will place that very same object at all locations. This behavior can be confusing, especial…

---

## [Managing temporaries](https://discourse.julialang.org/t/managing-temporaries/78890)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 1\
**Last updated:** [April 2, 2022, 1:26am UTC](https://discourse.julialang.org/t/managing-temporaries/78890 "2022-04-02T01:26:42Z")

</div>

I’ve been told that C++ can now manage temporary matrices in loops automatically. For instance, for (...) { // create B, D K += B' \* D \* B \* Jw } would apparently allocate temporaries only once, before the …

---

## [Precompile: Why?](https://discourse.julialang.org/t/precompile-why/78770)

<div class="topic-metadata">

**Author:** [@chelseas](https://discourse.julialang.org/u/chelseas)\
**Replies:** 30\
**Last updated:** [April 1, 2022, 5:50pm UTC](https://discourse.julialang.org/t/precompile-why/78770 "2022-04-01T17:50:57Z")

</div>

For compiled languages like C++, you generally use external libraries that you download in a format that is already compiled. Then you compile your own code when you want to run it. This takes time, but it’s just part of…

---

## [Joining arrays of vectors of abritrary lengths](https://discourse.julialang.org/t/joining-arrays-of-vectors-of-abritrary-lengths/78880)

<div class="topic-metadata">

**Author:** [@juham58](https://discourse.julialang.org/u/juham58)\
**Replies:** 3\
**Last updated:** [April 1, 2022, 4:54pm UTC](https://discourse.julialang.org/t/joining-arrays-of-vectors-of-abritrary-lengths/78880 "2022-04-01T16:54:01Z")

</div>

Hi, I need to use arrays in which each element is a vector of arbitrary length. In itself, it works fine but when I try to append! an element to another array of vectors, it appends the vector to every elements of the t…

---

## [Representing Charts (Differential Geometry)](https://discourse.julialang.org/t/representing-charts-differential-geometry/78882)

<div class="topic-metadata">

**Author:** [@Veenty](https://discourse.julialang.org/u/Veenty)\
**Replies:** 0\
**Last updated:** [April 1, 2022, 4:46pm UTC](https://discourse.julialang.org/t/representing-charts-differential-geometry/78882 "2022-04-01T16:46:02Z")

</div>

Hi! I’m trying to implement local charts, like in differential geometry. And I’m not really sure what would be the best way to do it in Julia. A chart is a pair (U, f), U is an open set and f is a function from the open…

---

## [Custom grid in Plots.jl](https://discourse.julialang.org/t/custom-grid-in-plots-jl/78877)

<div class="topic-metadata">

**Author:** [@stepanzh](https://discourse.julialang.org/u/stepanzh)\
**Replies:** 1\
**Last updated:** [April 1, 2022, 3:56pm UTC](https://discourse.julialang.org/t/custom-grid-in-plots-jl/78877 "2022-04-01T15:56:34Z")

</div>

I’m using Plots.jl and want to specify grid as shown in the picture below I have small experience with the package. So, how can I draw the grid? Built-in properties? Third-party addons for Plots.jl? Imitate the grid…

---

## [I am having a versioning problem](https://discourse.julialang.org/t/i-am-having-a-versioning-problem/78866)

<div class="topic-metadata">

**Author:** [@matthiashimmelmann](https://discourse.julialang.org/u/matthiashimmelmann)\
**Replies:** 10\
**Last updated:** [April 1, 2022, 2:17pm UTC](https://discourse.julialang.org/t/i-am-having-a-versioning-problem/78866 "2022-04-01T14:17:24Z")

</div>

I am maintaining the package Implicit3DPlotting (currently @0.2.2 in the registry) and I recently discovered that when adding from the registry, the old version 0.1.6 gets installed. Even when adding specific versions to…

---

## [Counting special characters ü, å, ø, etc](https://discourse.julialang.org/t/counting-special-characters-u-a-o-etc/78858)

<div class="topic-metadata">

**Author:** [@etas](https://discourse.julialang.org/u/etas)\
**Replies:** 11\
**Last updated:** [April 1, 2022, 1:25pm UTC](https://discourse.julialang.org/t/counting-special-characters-u-a-o-etc/78858 "2022-04-01T13:25:17Z")

</div>

Hi, I have some strings with a name and a distance such as "Haugastøl, Km 0". I want to remove the km point with the chop() function but what’s interesting is that chop() and length() count ø as one character but not fin…

---

## [Resizing images in docs](https://discourse.julialang.org/t/resizing-images-in-docs/21721)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 19\
**Last updated:** [March 11, 2019, 7:23pm UTC](https://discourse.julialang.org/t/resizing-images-in-docs/21721 "2019-03-11T19:23:55Z")

</div>

Is there a way to control the image size of images in documentation made with Documenter? I created this Map projections example but the images are too big. Found this page about styling images with Markdown but none of…

---

## [inv(I::UniformScaling{Bool}) = UniformScaling{Float64}](https://discourse.julialang.org/t/inv-i-uniformscaling-bool-uniformscaling-float64/78854)

<div class="topic-metadata">

**Author:** [@fgerick](https://discourse.julialang.org/u/fgerick)\
**Replies:** 2\
**Last updated:** [April 1, 2022, 11:31am UTC](https://discourse.julialang.org/t/inv-i-uniformscaling-bool-uniformscaling-float64/78854 "2022-04-01T11:31:32Z")

</div>

This seems like it shouldn’t convert to a UniformScaling{Float64}: julia\> inv(I) UniformScaling{Float64} 1.0\*I at least I don’t see a reason for this and it could cause some type instabilities!? Possibly there is a rea…

---

## [How to get links when using @which in REPL](https://discourse.julialang.org/t/how-to-get-links-when-using-which-in-repl/78855)

<div class="topic-metadata">

**Author:** [@Rex\_Wang](https://discourse.julialang.org/u/Rex_Wang)\
**Replies:** 3\
**Last updated:** [April 1, 2022, 11:10am UTC](https://discourse.julialang.org/t/how-to-get-links-when-using-which-in-repl/78855 "2022-04-01T11:10:06Z")

</div>

When typing @which(occursin(1)) in Jupyter-notebook, I get the following occursin(haystack) in Base at strings/search.jl:635 However, typing the same message in REPL, I get only plain text occursin(haystack) in Bas…

---

## [Debugging distributed code](https://discourse.julialang.org/t/debugging-distributed-code/78857)

<div class="topic-metadata">

**Author:** [@Casper](https://discourse.julialang.org/u/Casper)\
**Replies:** 0\
**Last updated:** [April 1, 2022, 9:23am UTC](https://discourse.julialang.org/t/debugging-distributed-code/78857 "2022-04-01T09:23:41Z")

</div>

The build in debugger from VSCode gets lost once a distributed process is started, is there a way to debug distributed code?

---

## [Strange error](https://discourse.julialang.org/t/strange-error/78851)

<div class="topic-metadata">

**Author:** [@RogerP](https://discourse.julialang.org/u/RogerP)\
**Replies:** 3\
**Last updated:** [April 1, 2022, 8:27am UTC](https://discourse.julialang.org/t/strange-error/78851 "2022-04-01T08:27:48Z")

</div>

Could someone explain to me what is happening here? Try running mwe1() and then mwe2() function mwe1() initfloat::Vector{Float64} = zeros(1) Φ::Vector{Float64} = initfloat Θ̇::Vector{Float64} = i…

---

## [An idea for putting imports inside of Julia functions](https://discourse.julialang.org/t/an-idea-for-putting-imports-inside-of-julia-functions/78840)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 2\
**Last updated:** [April 1, 2022, 6:13am UTC](https://discourse.julialang.org/t/an-idea-for-putting-imports-inside-of-julia-functions/78840 "2022-04-01T06:13:37Z")

</div>

I’ve often wanted to put imports inside of functions to delay loading potentially slow-to-load packages until I really need them in a given session (a habit from Python, but maybe even more useful in Julia due to latency…

---

## [A string related MAT file question](https://discourse.julialang.org/t/a-string-related-mat-file-question/78836)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 2\
**Last updated:** [March 31, 2022, 8:27pm UTC](https://discourse.julialang.org/t/a-string-related-mat-file-question/78836 "2022-03-31T20:27:35Z")

</div>

My variables are stored as Var1 and Var2 in my MAT file. My goal is to write a loop so that I can read them out one at a time. Why doesn’t the below work? using MAT; F1 = matopen("Path1/File1.mat"); for i ∈ \["Var1", "V…

---

## [Strategies to use ReverseDiff.jl with NamedTuples (or ComponentArrays)](https://discourse.julialang.org/t/strategies-to-use-reversediff-jl-with-namedtuples-or-componentarrays/78760)

<div class="topic-metadata">

**Author:** [@roualdes](https://discourse.julialang.org/u/roualdes)\
**Replies:** 5\
**Last updated:** [March 31, 2022, 8:21pm UTC](https://discourse.julialang.org/t/strategies-to-use-reversediff-jl-with-namedtuples-or-componentarrays/78760 "2022-03-31T20:21:36Z")

</div>

It seems like ReverseDiff.jl can be used on functions that accept NamedTuples, for instance in LogDensityProblems.jl and TransformVariables.jl, but I can’t figure out the details. Will you help me understand how I could…

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

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