# General Usage

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

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

**Page:** 655

---

## [Help with increasing performance of specific function](https://discourse.julialang.org/t/help-with-increasing-performance-of-specific-function/53737)

<div class="topic-metadata">

**Author:** [@claudio20497](https://discourse.julialang.org/u/claudio20497)\
**Replies:** 8\
**Last updated:** [January 21, 2021, 10:44pm UTC](https://discourse.julialang.org/t/help-with-increasing-performance-of-specific-function/53737 "2021-01-21T22:44:39Z")

</div>

Hello, I’m trying to translate in Julia the doubleCenter function from this article. The function takes a matrix as an argument, and doubly centers it, meaning that it subtracts to each element the mean of its row and t…

---

## [Creating Column Matrix with Array Literals](https://discourse.julialang.org/t/creating-column-matrix-with-array-literals/53742)

<div class="topic-metadata">

**Author:** [@dariush-bahrami](https://discourse.julialang.org/u/dariush-bahrami)\
**Replies:** 4\
**Last updated:** [January 21, 2021, 8:46pm UTC](https://discourse.julialang.org/t/creating-column-matrix-with-array-literals/53742 "2021-01-21T20:46:35Z")

</div>

Hi, How we can create a column matrix (i.e. nx1) with array literals? I am aware of other ways for achieving this such as using initializer functions such as “zeros” and “ones”. but how we can do this with array literals…

---

## [CSV, white spaces and data type. Force Float on empty fields](https://discourse.julialang.org/t/csv-white-spaces-and-data-type-force-float-on-empty-fields/53702)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 23\
**Last updated:** [January 21, 2021, 7:48pm UTC](https://discourse.julialang.org/t/csv-white-spaces-and-data-type-force-float-on-empty-fields/53702 "2021-01-21T19:48:06Z")

</div>

Hi, I have a csv file where either the column names or the column themselves have spaces like # date , lat , lon , smajax , sminax , strike, q , 1904-04-04 10:02:34.56 , 41.802 , 23.108 , …

---

## [Iteration/getindex performance of AbstractArray wrapper-types](https://discourse.julialang.org/t/iteration-getindex-performance-of-abstractarray-wrapper-types/53729)

<div class="topic-metadata">

**Author:** [@tchr](https://discourse.julialang.org/u/tchr)\
**Replies:** 2\
**Last updated:** [January 21, 2021, 7:07pm UTC](https://discourse.julialang.org/t/iteration-getindex-performance-of-abstractarray-wrapper-types/53729 "2021-01-21T19:07:03Z")

</div>

I hit what I think is a surprising performance-snag for custom array-wrapper types that subtype AbstractArray. The issue is best illustrated by example: suppose I define a thin wrapper over a vector, like so: import Ba…

---

## [Non-orthogonality in SVD solver!](https://discourse.julialang.org/t/non-orthogonality-in-svd-solver/53733)

<div class="topic-metadata">

**Author:** [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)\
**Replies:** 0\
**Last updated:** [January 21, 2021, 4:39pm UTC](https://discourse.julialang.org/t/non-orthogonality-in-svd-solver/53733 "2021-01-21T16:39:51Z")

</div>

Hi, I am using KrylovKit to compute the SVD of a sparse, asymmetric NXN matrix. The creation of the matrix comes from some previous complicated normalization steps. The SVD is supposed to decompose K as K = U\\Lambda V^\*,…

---

## [Syntactical sugar for \`getfield\`](https://discourse.julialang.org/t/syntactical-sugar-for-getfield/52075)

<div class="topic-metadata">

**Author:** [@gcalderone](https://discourse.julialang.org/u/gcalderone)\
**Replies:** 18\
**Last updated:** [January 21, 2021, 4:19pm UTC](https://discourse.julialang.org/t/syntactical-sugar-for-getfield/52075 "2021-01-21T16:19:07Z")

</div>

Each time I implement a new getproperty method for a structure I found myself filling the code with lengthy (and sometimes nested) calls to getfield. So far the best looking solution I came up with is: ⋄ = getfield …

---

## [The probability of density function](https://discourse.julialang.org/t/the-probability-of-density-function/53725)

<div class="topic-metadata">

**Author:** [@marouane1994](https://discourse.julialang.org/u/marouane1994)\
**Replies:** 5\
**Last updated:** [January 21, 2021, 3:30pm UTC](https://discourse.julialang.org/t/the-probability-of-density-function/53725 "2021-01-21T15:30:04Z")

</div>

I want to test an MCMC code for a Gaussian distribution witha standard deviation of 0.1and for random values of the mean using Distributions using LinearAlgebra using Plots sigma=0.1 log\_target(mu)= log((1/sigma\*sqrt(p…

---

## [Why does my program's performance vary so much from run to run? Can it be fixed?](https://discourse.julialang.org/t/why-does-my-programs-performance-vary-so-much-from-run-to-run-can-it-be-fixed/53678)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 11\
**Last updated:** [January 20, 2021, 11:02pm UTC](https://discourse.julialang.org/t/why-does-my-programs-performance-vary-so-much-from-run-to-run-can-it-be-fixed/53678 "2021-01-20T23:02:01Z")

</div>

While I was looking into optimizing my pure Julia program, I noticed something very unpleasant: its run time varies a great deal between some runs even though its input and code stay the same, and even though the system …

---

## [Github actions StackOverflowError](https://discourse.julialang.org/t/github-actions-stackoverflowerror/53720)

<div class="topic-metadata">

**Author:** [@arzwa](https://discourse.julialang.org/u/arzwa)\
**Replies:** 2\
**Last updated:** [January 21, 2021, 2:07pm UTC](https://discourse.julialang.org/t/github-actions-stackoverflowerror/53720 "2021-01-21T14:07:04Z")

</div>

I’m trying to set up a GitHub actions workflow for testing a package. While my documentation builds fine, my tests error in a way I don’t understand. I get a StackOverflowError I cannot reproduce, and which does not make…

---

## [Solving ode takes too long compared to python](https://discourse.julialang.org/t/solving-ode-takes-too-long-compared-to-python/53719)

<div class="topic-metadata">

**Author:** [@arif](https://discourse.julialang.org/u/arif)\
**Replies:** 7\
**Last updated:** [January 21, 2021, 1:08pm UTC](https://discourse.julialang.org/t/solving-ode-takes-too-long-compared-to-python/53719 "2021-01-21T13:08:04Z")

</div>

Hi, I have tried Julia on and off for the last 5 years. Recently I thought of using Julia exclusively for a course on Astrophysics and my first task was to solve a set of four ordinary differential equations. I am using …

---

## [Run file and print line results as in REPL](https://discourse.julialang.org/t/run-file-and-print-line-results-as-in-repl/53651)

<div class="topic-metadata">

**Author:** [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Replies:** 4\
**Last updated:** [January 21, 2021, 8:29am UTC](https://discourse.julialang.org/t/run-file-and-print-line-results-as-in-repl/53651 "2021-01-21T08:29:00Z")

</div>

How can I run a file and obtain the results in the screen as if the file were executed line by line in the REPL? For example, if I have the file “file.jl”: a = 1 b = 1 c = a+b and run it from the shell ~$ julia file.j…

---

## [\`@btime\` appears to force specialization, does this give misleading timings?](https://discourse.julialang.org/t/btime-appears-to-force-specialization-does-this-give-misleading-timings/53611)

<div class="topic-metadata">

**Author:** [@Benny](https://discourse.julialang.org/u/Benny)\
**Replies:** 5\
**Last updated:** [January 21, 2021, 8:41am UTC](https://discourse.julialang.org/t/btime-appears-to-force-specialization-does-this-give-misleading-timings/53611 "2021-01-21T08:41:02Z")

</div>

Julia normally avoids specializing on Type, but it can be triggered by @code\_warntype and similar macros (has a mention in Performance Tips; currently open issue 32834; illustrated well in issue 23749). It also appears t…

---

## [Evolutionary.jl - positive integers](https://discourse.julialang.org/t/evolutionary-jl-positive-integers/53652)

<div class="topic-metadata">

**Author:** [@TheMEGuy](https://discourse.julialang.org/u/TheMEGuy)\
**Replies:** 3\
**Last updated:** [January 21, 2021, 2:01am UTC](https://discourse.julialang.org/t/evolutionary-jl-positive-integers/53652 "2021-01-21T02:01:42Z")

</div>

Hi, is there a way to tell the optimizer, that the variables should be natural numbers? I am currently trying to implement this using PenaltyConstraints(). Is there another way? Thanks

---

## [How to make a function accept children of an abstract type?](https://discourse.julialang.org/t/how-to-make-a-function-accept-children-of-an-abstract-type/53698)

<div class="topic-metadata">

**Author:** [@Visipi](https://discourse.julialang.org/u/Visipi)\
**Replies:** 4\
**Last updated:** [January 21, 2021, 1:53am UTC](https://discourse.julialang.org/t/how-to-make-a-function-accept-children-of-an-abstract-type/53698 "2021-01-21T01:53:35Z")

</div>

I have an abstract type “Foo” that has a number of children: “Bar”, “Car”, “Dar”. I also have a function “f” that takes an array of “Foo” objects as arguments. function f(a::Array{Foo, 1}) But when I try to run the fu…

---

## [Question about method dispatch with composite types](https://discourse.julialang.org/t/question-about-method-dispatch-with-composite-types/53680)

<div class="topic-metadata">

**Author:** [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Replies:** 2\
**Last updated:** [January 20, 2021, 7:01pm UTC](https://discourse.julialang.org/t/question-about-method-dispatch-with-composite-types/53680 "2021-01-20T19:01:43Z")

</div>

In the bellow script, being dc.x and dc.y equal to 1 the default, how may I (if possible) create the following methods: divide(a,Clock()) and divide(a,Pendulum()) returning the same as divide(a,CLock(1)), divide(a,Pen…

---

## [Converting an Array of Byte to Array{T}](https://discourse.julialang.org/t/converting-an-array-of-byte-to-array-t/53676)

<div class="topic-metadata">

**Author:** [@Clonkk](https://discourse.julialang.org/u/Clonkk)\
**Replies:** 2\
**Last updated:** [January 20, 2021, 4:25pm UTC](https://discourse.julialang.org/t/converting-an-array-of-byte-to-array-t/53676 "2021-01-20T16:25:31Z")

</div>

Hello, I have binary data read from SQLite database in the form of Array{Uint8}. What would be the best solution to convert this binary data into an Array{T} (convert function perform element wise conversion and thus d…

---

## [Trailing zeros](https://discourse.julialang.org/t/trailing-zeros/53549)

<div class="topic-metadata">

**Author:** [@saraflgarcia](https://discourse.julialang.org/u/saraflgarcia)\
**Replies:** 13\
**Last updated:** [January 20, 2021, 10:39am UTC](https://discourse.julialang.org/t/trailing-zeros/53549 "2021-01-20T10:39:55Z")

</div>

Hi everyone, I want to convert a number to a string, but keeping the trailing zeros: string(1) \> “1” string(1.0) \> “1.0” string(1.00) \> “1.0” - How do I get the result “1.00”? Thanks to all.

---

## [Looking for code to solve (surely common) 'embarrassing parallelism' multithreading use-case](https://discourse.julialang.org/t/looking-for-code-to-solve-surely-common-embarrassing-parallelism-multithreading-use-case/53527)

<div class="topic-metadata">

**Author:** [@Sean\_Matthews](https://discourse.julialang.org/u/Sean_Matthews)\
**Replies:** 16\
**Last updated:** [January 20, 2021, 6:12am UTC](https://discourse.julialang.org/t/looking-for-code-to-solve-surely-common-embarrassing-parallelism-multithreading-use-case/53527 "2021-01-20T06:12:06Z")

</div>

I am looking for code that can solve the following (multi-core, shared memory) parallelisation problem, which is surely so common that a well implemented solution must exist out there. I have N cores. I have a list (…

---

## [Import custom Julia module from C & use it](https://discourse.julialang.org/t/import-custom-julia-module-from-c-use-it/43979)

<div class="topic-metadata">

**Author:** [@Clonkk](https://discourse.julialang.org/u/Clonkk)\
**Replies:** 3\
**Last updated:** [July 30, 2020, 2:08pm UTC](https://discourse.julialang.org/t/import-custom-julia-module-from-c-use-it/43979 "2020-07-30T14:08:02Z")

</div>

Hello, I’m trying to import a local Julia module from C and call a function; but jl\_get\_function always return a null pointer. I based my code on this topic and this SO question, but nothing I’ve tried worked. This i…

---

## [Embedding a custom Julia module in C++](https://discourse.julialang.org/t/embedding-a-custom-julia-module-in-c/53628)

<div class="topic-metadata">

**Author:** [@JuliaPerson](https://discourse.julialang.org/u/JuliaPerson)\
**Replies:** 0\
**Last updated:** [January 19, 2021, 6:29pm UTC](https://discourse.julialang.org/t/embedding-a-custom-julia-module-in-c/53628 "2021-01-19T18:29:00Z")

</div>

Hello, I’m trying to do something very similar to Import custom Julia module from C & use it: but in C++. I’ve tried compiling this example in C++, but I am receiving null output from the function. As suggested, I’m doi…

---

## [Why is reversediff slow?](https://discourse.julialang.org/t/why-is-reversediff-slow/53541)

<div class="topic-metadata">

**Author:** [@fmeulen](https://discourse.julialang.org/u/fmeulen)\
**Replies:** 11\
**Last updated:** [January 19, 2021, 6:02pm UTC](https://discourse.julialang.org/t/why-is-reversediff-slow/53541 "2021-01-19T18:02:00Z")

</div>

I am trying to use automatic differentiation to obtain the gradient of a function with scalar-valued output. Contrary to what I had expected, reverse differentiation is much slower than forward differentiation. Can anyo…

---

## [Would it be possible to update the documentation to include how to implement isequal() and hash()](https://discourse.julialang.org/t/would-it-be-possible-to-update-the-documentation-to-include-how-to-implement-isequal-and-hash/53518)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 14\
**Last updated:** [January 19, 2021, 5:48pm UTC](https://discourse.julialang.org/t/would-it-be-possible-to-update-the-documentation-to-include-how-to-implement-isequal-and-hash/53518 "2021-01-19T17:48:42Z")

</div>

Both the C# and Python documentation include clear instructions on how to implement equals and hash code methods and I was wondering if we could do the same for Julia. For example, the Base.hash() documentation says: N…

---

## [ArgumentError ReverseDiff: cannot reinterpret](https://discourse.julialang.org/t/argumenterror-reversediff-cannot-reinterpret/53618)

<div class="topic-metadata">

**Author:** [@fmeulen](https://discourse.julialang.org/u/fmeulen)\
**Replies:** 4\
**Last updated:** [January 19, 2021, 5:45pm UTC](https://discourse.julialang.org/t/argumenterror-reversediff-cannot-reinterpret/53618 "2021-01-19T17:45:50Z")

</div>

I attempt to used reverse mode differentiation. A very much simplified version of the function call is using StaticArrays using ReverseDiff const Po{T} = SArray{Tuple{2},T,1,2} # point in R2 function ff(x) T …

---

## [Separating Numbers from Letters (from anything else) using Regex](https://discourse.julialang.org/t/separating-numbers-from-letters-from-anything-else-using-regex/53613)

<div class="topic-metadata">

**Author:** [@danilo-bc](https://discourse.julialang.org/u/danilo-bc)\
**Replies:** 2\
**Last updated:** [January 19, 2021, 4:16pm UTC](https://discourse.julialang.org/t/separating-numbers-from-letters-from-anything-else-using-regex/53613 "2021-01-19T16:16:48Z")

</div>

I’m trying to incorporate regular expressions on some of my pattern matching functions, but I’m still having a hard time figuring out how to use them to separate my strings. Starting off easily, I want to separate numbe…

---

## [Parameters of the model: free, fixed, constrained](https://discourse.julialang.org/t/parameters-of-the-model-free-fixed-constrained/53501)

<div class="topic-metadata">

**Author:** [@misha\_mikhasenko](https://discourse.julialang.org/u/misha_mikhasenko)\
**Replies:** 3\
**Last updated:** [January 19, 2021, 11:57am UTC](https://discourse.julialang.org/t/parameters-of-the-model-free-fixed-constrained/53501 "2021-01-19T11:57:26Z")

</div>

I am seeking advice on the way to store parameters of a model with a metadata free , fixed , or constrained. NamedTuples are already good for the pairs of (:name, :value) p = (a = 1.1, b = 3.3) I am considering two opt…

---

## [Base.factorial: Extending and overwriting functions in SpecialFunctions](https://discourse.julialang.org/t/base-factorial-extending-and-overwriting-functions-in-specialfunctions/53486)

<div class="topic-metadata">

**Author:** [@mr.red](https://discourse.julialang.org/u/mr.red)\
**Replies:** 1\
**Last updated:** [January 19, 2021, 11:46am UTC](https://discourse.julialang.org/t/base-factorial-extending-and-overwriting-functions-in-specialfunctions/53486 "2021-01-19T11:46:14Z")

</div>

The Base.factorial function supplies the following methods julia\> methods(factorial) # 7 methods for generic function "factorial": \[1\] factorial(n::UInt128) in Base at combinatorics.jl:26 \[2\] factorial(n::Int128) in Bas…

---

## [Simple CUDA sum kernel](https://discourse.julialang.org/t/simple-cuda-sum-kernel/53594)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 0\
**Last updated:** [January 19, 2021, 8:43am UTC](https://discourse.julialang.org/t/simple-cuda-sum-kernel/53594 "2021-01-19T08:43:14Z")

</div>

I am trying to write a simple CUDA.jl sum kernel. However I always get: ERROR: LoadError: CUDA error: an illegal memory access was encountered (code 700, ERROR\_ILLEGAL\_AD DRESS) Any ideas? Here is my code: using CUDA …

---

## [How to filter out errors due to alias of Type name when building documentation?](https://discourse.julialang.org/t/how-to-filter-out-errors-due-to-alias-of-type-name-when-building-documentation/53588)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 1\
**Last updated:** [January 19, 2021, 8:30am UTC](https://discourse.julialang.org/t/how-to-filter-out-errors-due-to-alias-of-type-name-when-building-documentation/53588 "2021-01-19T08:30:07Z")

</div>

For example, the summary of objects of type Array{T,1} has been changed to Vector{T} in julia1.6. This makes the documentation build of a package fail on nightly. I wonder if there is a way to insert the correct output i…

---

## [Trying to understand sort!(), findfirst()](https://discourse.julialang.org/t/trying-to-understand-sort-findfirst/53585)

<div class="topic-metadata">

**Author:** [@Jared\_shay](https://discourse.julialang.org/u/Jared_shay)\
**Replies:** 4\
**Last updated:** [January 19, 2021, 7:49am UTC](https://discourse.julialang.org/t/trying-to-understand-sort-findfirst/53585 "2021-01-19T07:49:41Z")

</div>

So far, this community is giving a lot of helps to answer beginner level julialang question. I am still in the early stage of learning julialang, so here I got a few new questions that might need community help. I am a …

---

## [\[JSON.jl\] About empty structs](https://discourse.julialang.org/t/json-jl-about-empty-structs/53571)

<div class="topic-metadata">

**Author:** [@TommyXR](https://discourse.julialang.org/u/TommyXR)\
**Replies:** 1\
**Last updated:** [January 19, 2021, 6:50am UTC](https://discourse.julialang.org/t/json-jl-about-empty-structs/53571 "2021-01-19T06:50:53Z")

</div>

Hello. The package JSON.jl made the interesting design decision to make singleton structs unserializable. This behavior is implemented in this function in the source code. function lower(a) if nfields(a) \> 0 …

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

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