# General Usage

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

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

**Page:** 569

---

## [Fast f(x) ∂f∂x and ∂2f∂x2](https://discourse.julialang.org/t/fast-f-x-f-x-and-2f-x2/65569)

<div class="topic-metadata">

**Author:** [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Replies:** 5\
**Last updated:** [July 30, 2021, 9:51pm UTC](https://discourse.julialang.org/t/fast-f-x-f-x-and-2f-x2/65569 "2021-07-30T21:51:55Z")

</div>

Hi, im trying to make a fast evaluation of the value, first and second derivative, in the least amount of forward passes as possible. i’m using at the moment this function: using DiffResults, StaticArrays, ForwardDiff f…

---

## [Fastest way to print many numbers to text file](https://discourse.julialang.org/t/fastest-way-to-print-many-numbers-to-text-file/65537)

<div class="topic-metadata">

**Author:** [@PeterB](https://discourse.julialang.org/u/PeterB)\
**Replies:** 18\
**Last updated:** [July 30, 2021, 9:51pm UTC](https://discourse.julialang.org/t/fastest-way-to-print-many-numbers-to-text-file/65537 "2021-07-30T21:51:41Z")

</div>

EDIT: I found one speedup myself (see my answer below) but still interested in replies… I have a critical loop which looks like this: for j in 1:about\_1000 x = a\_simple\_calculation() @printf(op, " %g", x) # t…

---

## [Problem initializing dataframe column types](https://discourse.julialang.org/t/problem-initializing-dataframe-column-types/65561)

<div class="topic-metadata">

**Author:** [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Replies:** 6\
**Last updated:** [July 30, 2021, 9:40pm UTC](https://discourse.julialang.org/t/problem-initializing-dataframe-column-types/65561 "2021-07-30T21:40:32Z")

</div>

I’m having trouble initializing an empty dataframe intended to hold integer and floating point values: julia\> using DataFrames julia\> df = DataFrame(\[Int\[\],Float64\[\]\], :auto) 0×2 DataFrame julia\> push!(df,Any\[1,10.0\])…

---

## [Reading multiple integers from the same line without string manipulation](https://discourse.julialang.org/t/reading-multiple-integers-from-the-same-line-without-string-manipulation/65572)

<div class="topic-metadata">

**Author:** [@burntclaw](https://discourse.julialang.org/u/burntclaw)\
**Replies:** 1\
**Last updated:** [July 30, 2021, 8:55pm UTC](https://discourse.julialang.org/t/reading-multiple-integers-from-the-same-line-without-string-manipulation/65572 "2021-07-30T20:55:53Z")

</div>

Hi all! I’m relatively new to Julia. I’m wondering if there is a way to read a line of integers like this in a file without using readline(s) and then parsing and manipulating the resulting string. The text file I want t…

---

## [Segmentation fault in julia nightly when running standard tests on github CI](https://discourse.julialang.org/t/segmentation-fault-in-julia-nightly-when-running-standard-tests-on-github-ci/65048)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 1\
**Last updated:** [July 30, 2021, 6:50pm UTC](https://discourse.julialang.org/t/segmentation-fault-in-julia-nightly-when-running-standard-tests-on-github-ci/65048 "2021-07-30T18:50:32Z")

</div>

Just run into this error when running the standard tests of my new package ExtensibleEffects.jl under julia nightly. On Julia 1.6 everything runs smoothly. Does someone know whether I should push this to github julia? h…

---

## [Omitting type parameters on dispatch: accepted or implementation detail?](https://discourse.julialang.org/t/omitting-type-parameters-on-dispatch-accepted-or-implementation-detail/65552)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 2\
**Last updated:** [July 30, 2021, 2:31pm UTC](https://discourse.julialang.org/t/omitting-type-parameters-on-dispatch-accepted-or-implementation-detail/65552 "2021-07-30T14:31:30Z")

</div>

I am unsure if omitting additional type parameters on dispatch is an accepted and stable language behavior, or if it should be avoided, meaning doing things like this: julia\> using StaticArrays julia\> f(x::SVector{3}) …

---

## [@test macro](https://discourse.julialang.org/t/test-macro/65531)

<div class="topic-metadata">

**Author:** [@Alois](https://discourse.julialang.org/u/Alois)\
**Replies:** 8\
**Last updated:** [July 30, 2021, 1:29pm UTC](https://discourse.julialang.org/t/test-macro/65531 "2021-07-30T13:29:38Z")

</div>

I understand that @assert 2 == 3; println("never") stops execution. But why does @test 2 == 3; println("never") abort execution, even with Error? I mean it is just a test which failed, but this should not result in a…

---

## [Finding row index of matrix](https://discourse.julialang.org/t/finding-row-index-of-matrix/65540)

<div class="topic-metadata">

**Author:** [@juls](https://discourse.julialang.org/u/juls)\
**Replies:** 5\
**Last updated:** [July 30, 2021, 12:15pm UTC](https://discourse.julialang.org/t/finding-row-index-of-matrix/65540 "2021-07-30T12:15:43Z")

</div>

Hi, I have two matrices : b = 6×2 Array{Int64,2}: 0 2 1 4 0 7 1 4 1 5 2 4 and a = 6×2 Array{Int64,2}: 0 2 0 7 1 4 1 4 1 5 2 4 I need to find row index, i of matrix b with respect to a. i.e.…

---

## [Monitoring GPU activity asynchronously (read data from the GPU)](https://discourse.julialang.org/t/monitoring-gpu-activity-asynchronously-read-data-from-the-gpu/65496)

<div class="topic-metadata">

**Author:** [@gil](https://discourse.julialang.org/u/gil)\
**Replies:** 1\
**Last updated:** [July 30, 2021, 8:59am UTC](https://discourse.julialang.org/t/monitoring-gpu-activity-asynchronously-read-data-from-the-gpu/65496 "2021-07-30T08:59:05Z")

</div>

Hi, Is there a way to continuously read a data array from the GPU (such as print it) while a kernel continues to update that data? in effect monitoring the kernel activity? for instance, I want a long-running kernel to…

---

## [How to use one DrWatson project in another DrWatson project?](https://discourse.julialang.org/t/how-to-use-one-drwatson-project-in-another-drwatson-project/65363)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 5\
**Last updated:** [July 30, 2021, 8:14am UTC](https://discourse.julialang.org/t/how-to-use-one-drwatson-project-in-another-drwatson-project/65363 "2021-07-30T08:14:35Z")

</div>

I love DrWatson, and I use it whenever I start a new project. I have some project (all it project\_A) which I also made a module (as insturcted in the documentation : Real World Examples · DrWatson.jl). Now I have anoth…

---

## [How to skip the error with try/catch statements?](https://discourse.julialang.org/t/how-to-skip-the-error-with-try-catch-statements/65527)

<div class="topic-metadata">

**Author:** [@Sebastian\_Mena](https://discourse.julialang.org/u/Sebastian_Mena)\
**Replies:** 1\
**Last updated:** [July 30, 2021, 1:39am UTC](https://discourse.julialang.org/t/how-to-skip-the-error-with-try-catch-statements/65527 "2021-07-30T01:39:04Z")

</div>

Hi, Do you know how to try with another option when first doesn’t work? For example: try var = first\_option #this variable sometimes works, but in some cases throw an error #so, when this var throw an error, I want t…

---

## [Algorithms design book / cookbook for Julia?](https://discourse.julialang.org/t/algorithms-design-book-cookbook-for-julia/64720)

<div class="topic-metadata">

**Author:** [@phendric](https://discourse.julialang.org/u/phendric)\
**Replies:** 28\
**Last updated:** [July 29, 2021, 11:11pm UTC](https://discourse.julialang.org/t/algorithms-design-book-cookbook-for-julia/64720 "2021-07-29T23:11:37Z")

</div>

Not having a computer science degree, I never took a course in design or analysis of algorithms + data structures at a non-beginner level. I’ve taken a beginning data structures course and implemented beginner algorithm…

---

## [Calling C with a tuple where I write the C to parse the tuple](https://discourse.julialang.org/t/calling-c-with-a-tuple-where-i-write-the-c-to-parse-the-tuple/65530)

<div class="topic-metadata">

**Author:** [@bootchk](https://discourse.julialang.org/u/bootchk)\
**Replies:** 0\
**Last updated:** [July 29, 2021, 10:32pm UTC](https://discourse.julialang.org/t/calling-c-with-a-tuple-where-i-write-the-c-to-parse-the-tuple/65530 "2021-07-29T22:32:31Z")

</div>

From Julia, I want to call a C program and pass a tuple. Tuple is variable length. Tuple is actually written by a third party. The domain is a GIMP plugin. A third party author will write the Julia, calling GIMP proc…

---

## [How to find the error line using try/catch statements?](https://discourse.julialang.org/t/how-to-find-the-error-line-using-try-catch-statements/65511)

<div class="topic-metadata">

**Author:** [@Sebastian\_Mena](https://discourse.julialang.org/u/Sebastian_Mena)\
**Replies:** 6\
**Last updated:** [July 29, 2021, 10:03pm UTC](https://discourse.julialang.org/t/how-to-find-the-error-line-using-try-catch-statements/65511 "2021-07-29T22:03:16Z")

</div>

Hi, I want to get the line number of an error using try/catch statements. try \[my\_function\] catch err println(err) #this only shows the name of the error #i want to print the line number of the error I hope you can h…

---

## [Faster default Base.sort! for Julia](https://discourse.julialang.org/t/faster-default-base-sort-for-julia/65508)

<div class="topic-metadata">

**Author:** [@viraltux](https://discourse.julialang.org/u/viraltux)\
**Replies:** 4\
**Last updated:** [July 29, 2021, 9:46pm UTC](https://discourse.julialang.org/t/faster-default-base-sort-for-julia/65508 "2021-07-29T21:46:21Z")

</div>

There are functions like factorial where Julia uses a factorial\_lookup function to directly return results from a table when the value is lower or equal to 20. Playing around with sorting algorithms I built a simple one…

---

## [Julia inner type-inference working](https://discourse.julialang.org/t/julia-inner-type-inference-working/65521)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 2\
**Last updated:** [July 29, 2021, 8:17pm UTC](https://discourse.julialang.org/t/julia-inner-type-inference-working/65521 "2021-07-29T20:17:59Z")

</div>

Hi all, I run over a very surprising type-inference difference. I always thought these two codes would be regarded identical to Julia’s compiler. make\_sigtype\_without\_bits(::Type{T}) where T\<:Tuple = Tuple{\_make\_sigtyp…

---

## [Inner product of functions on an interval with Trapz.jl](https://discourse.julialang.org/t/inner-product-of-functions-on-an-interval-with-trapz-jl/65505)

<div class="topic-metadata">

**Author:** [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Replies:** 3\
**Last updated:** [July 29, 2021, 7:49pm UTC](https://discourse.julialang.org/t/inner-product-of-functions-on-an-interval-with-trapz-jl/65505 "2021-07-29T19:49:19Z")

</div>

x = range(0.,π,length = 1000) u1 = sin.(x) u2 = cos.(x) ip = trapz(x,prod(hcat(u1,u2),dims=2)) AssertionError: Integration axis over yis incompatible withx. Make sure their length match! Can’t figure out why it’s not c…

---

## [Efficient maximum of a large matrix](https://discourse.julialang.org/t/efficient-maximum-of-a-large-matrix/65512)

<div class="topic-metadata">

**Author:** [@juliauser](https://discourse.julialang.org/u/juliauser)\
**Replies:** 3\
**Last updated:** [July 29, 2021, 7:35pm UTC](https://discourse.julialang.org/t/efficient-maximum-of-a-large-matrix/65512 "2021-07-29T19:35:17Z")

</div>

Hi, I have a matrix A = rand(M,N). I need to compute the maximum by column. Then compute the number of maximands in each row. What is an efficient way for large matrices? Here is what I am doing. B = (A.==maximum(A,dim…

---

## [Print boolean with PrettyTables.jl](https://discourse.julialang.org/t/print-boolean-with-prettytables-jl/65491)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 3\
**Last updated:** [July 29, 2021, 12:46pm UTC](https://discourse.julialang.org/t/print-boolean-with-prettytables-jl/65491 "2021-07-29T12:46:07Z")

</div>

I am printing a struct with PrettyTables.jl and would like boolean values to print out as true or false rather than Float64s. Is there a way to do this? Thank you. Example using PrettyTables struct M x::String …

---

## [How do I properly interpolate \`$\` in Markdown?](https://discourse.julialang.org/t/how-do-i-properly-interpolate-in-markdown/65482)

<div class="topic-metadata">

**Author:** [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Replies:** 8\
**Last updated:** [July 29, 2021, 11:20am UTC](https://discourse.julialang.org/t/how-do-i-properly-interpolate-in-markdown/65482 "2021-07-29T11:20:54Z")

</div>

I’m a bit confused by this: julia\> using Markdown julia\> x = 5; y = 7; z = 10; julia\> md""" Here I interpolate x: $(x). Then I also interpolate y: $(y) but for z I want a \\$ sign before the value: \\$$(z)m. …

---

## [Correct use of Timer](https://discourse.julialang.org/t/correct-use-of-timer/65490)

<div class="topic-metadata">

**Author:** [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)\
**Replies:** 0\
**Last updated:** [July 29, 2021, 11:09am UTC](https://discourse.julialang.org/t/correct-use-of-timer/65490 "2021-07-29T11:09:29Z")

</div>

I’m making use of Timer with a callback function to create a simple (?) purpose built cache-mechanism where large objects are moved to disk a short while after they have been used and I’m starting to feel that famous sen…

---

## [IRTools: How to wrap a function into Try / Catch block](https://discourse.julialang.org/t/irtools-how-to-wrap-a-function-into-try-catch-block/65489)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 0\
**Last updated:** [July 29, 2021, 10:51am UTC](https://discourse.julialang.org/t/irtools-how-to-wrap-a-function-into-try-catch-block/65489 "2021-07-29T10:51:47Z")

</div>

Hi all, I am using IRTools and would like to change my IR in such a way that the whole body is wrapped in a simple try ... catch e return nothing end I couldn’t find help in the documentation Home · IRTools and he…

---

## [Tullio boundary error for shifted stencil](https://discourse.julialang.org/t/tullio-boundary-error-for-shifted-stencil/65442)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 11\
**Last updated:** [July 29, 2021, 7:05am UTC](https://discourse.julialang.org/t/tullio-boundary-error-for-shifted-stencil/65442 "2021-07-29T07:05:35Z")

</div>

I implemented three versions of a 1D diffusion kernel, two with Tullio. The third version makes errors near the boundary. Is this illegal syntax and if so, can I fix this? I would like to avoid the second method in my ac…

---

## [Spark.jl install error](https://discourse.julialang.org/t/spark-jl-install-error/31000)

<div class="topic-metadata">

**Author:** [@jdhooghe](https://discourse.julialang.org/u/jdhooghe)\
**Replies:** 2\
**Last updated:** [July 29, 2021, 12:55am UTC](https://discourse.julialang.org/t/spark-jl-install-error/31000 "2021-07-29T00:55:20Z")

</div>

Good evening. I am attempting to install Spark.jl and an error is popping up. I am unsure what to look for given the following error message. Any help would be appreciated. Thank you. (v1.0) pkg\> build Spark Building …

---

## [Fast performance of array comprehension without allocations](https://discourse.julialang.org/t/fast-performance-of-array-comprehension-without-allocations/65352)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 14\
**Last updated:** [July 28, 2021, 8:07pm UTC](https://discourse.julialang.org/t/fast-performance-of-array-comprehension-without-allocations/65352 "2021-07-28T20:07:09Z")

</div>

I have the following code, where the nice and compact array comprehension code is 34x slower (880 ms vs 26 ms) than the written kernel and allocates memory where I would like to prevent this. Is there a way to make the s…

---

## [Julia sets in Julia, using Interact.jl - I'd like to get it faster](https://discourse.julialang.org/t/julia-sets-in-julia-using-interact-jl-id-like-to-get-it-faster/35533)

<div class="topic-metadata">

**Author:** [@zenon](https://discourse.julialang.org/u/zenon)\
**Replies:** 29\
**Last updated:** [July 28, 2021, 8:00pm UTC](https://discourse.julialang.org/t/julia-sets-in-julia-using-interact-jl-id-like-to-get-it-faster/35533 "2021-07-28T20:00:47Z")

</div>

Hi, after I talked about Julia to collegues some weeks ago, I somehow wanted to plot Julia sets (Wikipedia), simply because I thougt it to be a funny example. To play with it I used Interact.jl. The current result is t…

---

## [I have no idea what's wrong. Please help! ERROR: UndefVarError: i not defined](https://discourse.julialang.org/t/i-have-no-idea-whats-wrong-please-help-error-undefvarerror-i-not-defined/65416)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 6\
**Last updated:** [July 28, 2021, 6:00pm UTC](https://discourse.julialang.org/t/i-have-no-idea-whats-wrong-please-help-error-undefvarerror-i-not-defined/65416 "2021-07-28T18:00:04Z")

</div>

I hvave no idea what wrong . Please help! julia\> for i=1:length(przedzaly)-1 var\_name=Symbol("lista\_polaczona\_" \* string(litery\[i\])) println(var\_name) @eval $var\_name=lista\[przedzaly\[i\]+1:przedzaly\[…

---

## [Can I skip \`@boundscheck\` within a function](https://discourse.julialang.org/t/can-i-skip-boundscheck-within-a-function/65449)

<div class="topic-metadata">

**Author:** [@lieskjur](https://discourse.julialang.org/u/lieskjur)\
**Replies:** 4\
**Last updated:** [July 28, 2021, 5:08pm UTC](https://discourse.julialang.org/t/can-i-skip-boundscheck-within-a-function/65449 "2021-07-28T17:08:27Z")

</div>

Hi, suppose I am using a function function f(x,y) @boundscheck size(x) == size(y) || error("sizes do not match") x'y end written by someone else and I want to use arguments x = rand(2,2); y = rand(2). Is there a way …

---

## [Applying performance tips in library](https://discourse.julialang.org/t/applying-performance-tips-in-library/65452)

<div class="topic-metadata">

**Author:** [@rvignolo](https://discourse.julialang.org/u/rvignolo)\
**Replies:** 0\
**Last updated:** [July 28, 2021, 4:44pm UTC](https://discourse.julialang.org/t/applying-performance-tips-in-library/65452 "2021-07-28T16:44:37Z")

</div>

Hi all, I have implemented a neutron transport particle code in julia, NeutronTransport.jl, and I want it to be as fast as possible. Specifically, I just wanted to know if someone is interested in helping me implement: …

---

## [Simple Dykstra projection : Could it be faster?](https://discourse.julialang.org/t/simple-dykstra-projection-could-it-be-faster/65432)

<div class="topic-metadata">

**Author:** [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Replies:** 5\
**Last updated:** [July 28, 2021, 3:19pm UTC](https://discourse.julialang.org/t/simple-dykstra-projection-could-it-be-faster/65432 "2021-07-28T15:19:51Z")

</div>

Hi, I’m writting a simple Dykstra sheme for projecting a vector start onto equality constraints Ax = b and inequelity constraints x \>= 0. It works great, but I wander if it could be faster ? Here’s the current version …

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

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