# General Usage

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

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

**Page:** 816

---

## [Can we do "not-a-knot spline" in Julia?](https://discourse.julialang.org/t/can-we-do-not-a-knot-spline-in-julia/30955)

<div class="topic-metadata">

**Author:** [@ethanminfang](https://discourse.julialang.org/u/ethanminfang)\
**Replies:** 0\
**Last updated:** [November 11, 2019, 2:17pm UTC](https://discourse.julialang.org/t/can-we-do-not-a-knot-spline-in-julia/30955 "2019-11-11T14:17:20Z")

</div>

I don’t know if the Cubic Spline is “not-a-knot spline” as in Matlab, or? http://juliamath.github.io/Interpolations.jl/latest/api/#Public-API-1 Thanks! Best, Ethan

---

## [Elementwise mapping preserving static type](https://discourse.julialang.org/t/elementwise-mapping-preserving-static-type/30953)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 0\
**Last updated:** [November 11, 2019, 1:59pm UTC](https://discourse.julialang.org/t/elementwise-mapping-preserving-static-type/30953 "2019-11-11T13:59:05Z")

</div>

I would like to map a vector of vectors (the latter static) elementwise, so that the static type is preserved. # setup using StaticArrays, Test bs = \[SVector{4}(randn(4)...) for \_ in 1:9\] # 9 is "large" in real life A =…

---

## [Why is fld(a, b) so much slower than floor(a / b)?](https://discourse.julialang.org/t/why-is-fld-a-b-so-much-slower-than-floor-a-b/30914)

<div class="topic-metadata">

**Author:** [@zsoerenm](https://discourse.julialang.org/u/zsoerenm)\
**Replies:** 11\
**Last updated:** [November 11, 2019, 8:29am UTC](https://discourse.julialang.org/t/why-is-fld-a-b-so-much-slower-than-floor-a-b/30914 "2019-11-11T08:29:37Z")

</div>

I am using mod in a hot loop and I wondered why it is taking so much time. When I implemented mod myself with mod\_fast(a, b) = a - b \* floor(a / b) I found out it was a lot faster: julia\> @btime mod\_fast($(Ref(1232.2…

---

## [Is it a good idea to avoid Channel{Any} and how to avoid it?](https://discourse.julialang.org/t/is-it-a-good-idea-to-avoid-channel-any-and-how-to-avoid-it/30932)

<div class="topic-metadata">

**Author:** [@scelles](https://discourse.julialang.org/u/scelles)\
**Replies:** 0\
**Last updated:** [November 10, 2019, 10:06pm UTC](https://discourse.julialang.org/t/is-it-a-good-idea-to-avoid-channel-any-and-how-to-avoid-it/30932 "2019-11-10T22:06:03Z")

</div>

Hello, I have the following code ljulia\> lst\_a = \[1, 2, 3, 4\] 4-element Array{Int64,1}: 1 2 3 4 julia\> lst\_b = \[10.1, 11.1, 12.1, 13.1\] 4-element Array{Float64,1}: 10.1 11.1 12.1 13.1 julia\> function generato…

---

## [Rewind iterators](https://discourse.julialang.org/t/rewind-iterators/30930)

<div class="topic-metadata">

**Author:** [@scelles](https://discourse.julialang.org/u/scelles)\
**Replies:** 4\
**Last updated:** [November 10, 2019, 11:06pm UTC](https://discourse.julialang.org/t/rewind-iterators/30930 "2019-11-10T23:06:08Z")

</div>

Hello, I wonder if it’s possible to rewind iterator (ie without) recreating it. I tried julia\> itr = Iterators.Stateful(\[10,11,12\]) Base.Iterators.Stateful{Array{Int64,1},Union{Nothing, Tuple{Int64,Int64}}}(\[10, 11, 1…

---

## [Suggestions on code-style?](https://discourse.julialang.org/t/suggestions-on-code-style/30928)

<div class="topic-metadata">

**Author:** [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)\
**Replies:** 2\
**Last updated:** [November 10, 2019, 7:44pm UTC](https://discourse.julialang.org/t/suggestions-on-code-style/30928 "2019-11-10T19:44:12Z")

</div>

Hello, Below are two functions that do the same thing and I was wondering what is the more appropriate julian way to write and allocate output within these functions. In the second function, the only difference is that …

---

## [Discussion: Plans for Julia as a general-purpose language?](https://discourse.julialang.org/t/discussion-plans-for-julia-as-a-general-purpose-language/30861)

<div class="topic-metadata">

**Author:** [@erezsh](https://discourse.julialang.org/u/erezsh)\
**Replies:** 29\
**Last updated:** [November 10, 2019, 6:46pm UTC](https://discourse.julialang.org/t/discussion-plans-for-julia-as-a-general-purpose-language/30861 "2019-11-10T18:46:11Z")

</div>

Hi, first of all let me say that I know this is a big subject, but I couldn’t find any serious discussion about it, so I’m asking here. I think it’s obvious that Julia has a really good philosophical basis, and I believ…

---

## [How to cache dual numbers correctly /dual\_cache reinterpretation error](https://discourse.julialang.org/t/how-to-cache-dual-numbers-correctly-dual-cache-reinterpretation-error/30925)

<div class="topic-metadata">

**Author:** [@MatFi](https://discourse.julialang.org/u/MatFi)\
**Replies:** 1\
**Last updated:** [November 10, 2019, 6:44pm UTC](https://discourse.julialang.org/t/how-to-cache-dual-numbers-correctly-dual-cache-reinterpretation-error/30925 "2019-11-10T18:44:37Z")

</div>

Hi, I love the possibility to use Forwarddiff in DiffeEq, but now I’m encountering a problem with the caching of variables. let’s say I have a function foo that takes an array of size 10. Within this function I need a d…

---

## [In-place operations on matrices](https://discourse.julialang.org/t/in-place-operations-on-matrices/30908)

<div class="topic-metadata">

**Author:** [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)\
**Replies:** 6\
**Last updated:** [November 10, 2019, 5:05pm UTC](https://discourse.julialang.org/t/in-place-operations-on-matrices/30908 "2019-11-10T17:05:11Z")

</div>

When working with huge matrices, the limitations of the RAM is a real issue, and one would like to perform matrix operations in place if possible. Given a matrix A which occupies a sizable chunk of RAM, what is the best …

---

## [Get UndefRefError, when step into function](https://discourse.julialang.org/t/get-undefreferror-when-step-into-function/30909)

<div class="topic-metadata">

**Author:** [@nick-stu](https://discourse.julialang.org/u/nick-stu)\
**Replies:** 0\
**Last updated:** [November 10, 2019, 3:06am UTC](https://discourse.julialang.org/t/get-undefreferror-when-step-into-function/30909 "2019-11-10T03:06:14Z")

</div>

ubuntu 16.04.5 julia 0.6.4 atom 1.41.0 Hi all, I am new to julia. I try to run and debug the code “test/runtests.jl” from GitHub - jgorham/SteinDiscrepancy.jl: Practical tools for quantifying how well a sample appro…

---

## [Convincing Julia that 2 types are the same](https://discourse.julialang.org/t/convincing-julia-that-2-types-are-the-same/30863)

<div class="topic-metadata">

**Author:** [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Replies:** 4\
**Last updated:** [November 9, 2019, 2:04pm UTC](https://discourse.julialang.org/t/convincing-julia-that-2-types-are-the-same/30863 "2019-11-09T14:04:17Z")

</div>

Let’s say I have structs A and B. They are defined the same way, but weren’t specified to be part of a common abstract type. Is there a way to tell Julia that they’re really the same type, and that functions that accept…

---

## [LoadError: MbedTLS not installed properly, run Pkg.build("MbedTLS") ](https://discourse.julialang.org/t/loaderror-mbedtls-not-installed-properly-run-pkg-build-mbedtls/13497)

<div class="topic-metadata">

**Author:** [@wang\_lin](https://discourse.julialang.org/u/wang_lin)\
**Replies:** 1\
**Last updated:** [November 9, 2019, 4:48am UTC](https://discourse.julialang.org/t/loaderror-mbedtls-not-installed-properly-run-pkg-build-mbedtls/13497 "2019-11-09T04:48:32Z")

</div>

After installing the juliaPro, the following problems arise: Starting Julia… INFO: Precompiling module Atom. ERROR: LoadError: MbedTLS not installed properly, run Pkg.build(“MbedTLS”), restart Julia and try ag ain S…

---

## [Microsecond timing in Julia](https://discourse.julialang.org/t/microsecond-timing-in-julia/30877)

<div class="topic-metadata">

**Author:** [@fleecy](https://discourse.julialang.org/u/fleecy)\
**Replies:** 4\
**Last updated:** [November 9, 2019, 3:08am UTC](https://discourse.julialang.org/t/microsecond-timing-in-julia/30877 "2019-11-09T03:08:03Z")

</div>

I’d like to take stopwatch time measurements accurate to the microsecond. Is there another way to do this besides using @elapsed? I’d ideally like to avoid encapsulating my timed piece of code in a macro. Thanks!

---

## [SymTrididiagonal matrices performance and views allocations](https://discourse.julialang.org/t/symtrididiagonal-matrices-performance-and-views-allocations/24618)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 12\
**Last updated:** [November 8, 2019, 4:54pm UTC](https://discourse.julialang.org/t/symtrididiagonal-matrices-performance-and-views-allocations/24618 "2019-11-08T16:54:10Z")

</div>

Hi, I work on a toy 2D CFD solver and I wonder about the idiomatic Julian way to compute efficiently the product for all j \\in \[1:ny\] Pxy\[:,j\]=Lx\*Sxy\[:j\] where Lx is a a SymTridiagonal matrix of rank nx and Pxy and S…

---

## [Downloading packages fails on work network](https://discourse.julialang.org/t/downloading-packages-fails-on-work-network/30700)

<div class="topic-metadata">

**Author:** [@ElectronicTeaCup](https://discourse.julialang.org/u/ElectronicTeaCup)\
**Replies:** 17\
**Last updated:** [November 8, 2019, 1:48pm UTC](https://discourse.julialang.org/t/downloading-packages-fails-on-work-network/30700 "2019-11-08T13:48:33Z")

</div>

Hi, I’ve seen a couple of threads on this but to no avail. Here is my error message: IOError(Base.IOError(“connect: connection refused (ECONNREFUSED)”, -4078) during request(https://pkg.juliacomputing.com/package/.yan…

---

## [Improve test failures output to make it more readable](https://discourse.julialang.org/t/improve-test-failures-output-to-make-it-more-readable/30747)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 4\
**Last updated:** [November 8, 2019, 9:56am UTC](https://discourse.julialang.org/t/improve-test-failures-output-to-make-it-more-readable/30747 "2019-11-08T09:56:18Z")

</div>

Is any effort being undertaken to better format the output of test failures? For instance, I get something like: Evaluated: "\<html\>\<head\>\<title\>Genie test\</title\>\</head\>\<body\>\<div class=\\"template\\"\>\<h1\>Welcome\</h1\>\<di…

---

## [Optimizing performance (newcomer from Matlab)](https://discourse.julialang.org/t/optimizing-performance-newcomer-from-matlab/30825)

<div class="topic-metadata">

**Author:** [@jonneguyt](https://discourse.julialang.org/u/jonneguyt)\
**Replies:** 19\
**Last updated:** [November 8, 2019, 5:47am UTC](https://discourse.julialang.org/t/optimizing-performance-newcomer-from-matlab/30825 "2019-11-08T05:47:17Z")

</div>

Hi all, I am encountering slower than hoped for performance in my usage of Julia (in comparison to Matlab). I am sure that my coding style is largely responsible for this, but would appreciate any pointers. I am calcul…

---

## [How to execute a Julia code in a shell script without using a file jl?](https://discourse.julialang.org/t/how-to-execute-a-julia-code-in-a-shell-script-without-using-a-file-jl/30846)

<div class="topic-metadata">

**Author:** [@steph\_de\_paris](https://discourse.julialang.org/u/steph_de_paris)\
**Replies:** 2\
**Last updated:** [November 7, 2019, 10:18pm UTC](https://discourse.julialang.org/t/how-to-execute-a-julia-code-in-a-shell-script-without-using-a-file-jl/30846 "2019-11-07T22:18:01Z")

</div>

Hello, Is-it possible to execute a julia code inside a shell script by using something like: #!/bin/sh julia using Pkg ; Pkg.status() ; println("Hello the world !") Thanks very much ! NB : I know that it is possible …

---

## [Capturing a parameter of a type!](https://discourse.julialang.org/t/capturing-a-parameter-of-a-type/30842)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 2\
**Last updated:** [November 8, 2019, 12:32am UTC](https://discourse.julialang.org/t/capturing-a-parameter-of-a-type/30842 "2019-11-08T00:32:36Z")

</div>

abstract type MM{T} end capture(::Type{MM{T}}) where T = T capture(MM{Int}) Int64 julia\> const CMM{C} = MM{T} where T\<:C MM{T} where T\<:C where C julia\> capture(::Type{CMM{T}}) where T = T capture (generic function w…

---

## [VSCode crashed, julia process live containing data. Any way to access?](https://discourse.julialang.org/t/vscode-crashed-julia-process-live-containing-data-any-way-to-access/30826)

<div class="topic-metadata">

**Author:** [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Replies:** 1\
**Last updated:** [November 7, 2019, 9:38pm UTC](https://discourse.julialang.org/t/vscode-crashed-julia-process-live-containing-data-any-way-to-access/30826 "2019-11-07T21:38:47Z")

</div>

I had a script running all day but VSCode crashed overnight, taking the output with it. Is there any way to connect to the process and recover the data or determine if there was an error? Is there a log anywhere of the…

---

## [How to replace the charactors in the string?](https://discourse.julialang.org/t/how-to-replace-the-charactors-in-the-string/30778)

<div class="topic-metadata">

**Author:** [@Yan](https://discourse.julialang.org/u/Yan)\
**Replies:** 34\
**Last updated:** [November 7, 2019, 9:24pm UTC](https://discourse.julialang.org/t/how-to-replace-the-charactors-in-the-string/30778 "2019-11-07T21:24:18Z")

</div>

How to realize the following perl translating task in Julia? #/user/bin/perl my $string = ‘The cat sat on the mat’; $string =~ tr/ao/oL/; print “$string\\n”; #------------------------- The cot sot Ln the mot

---

## [Why does \`map\` of a named tuple and tuple return an array?](https://discourse.julialang.org/t/why-does-map-of-a-named-tuple-and-tuple-return-an-array/30468)

<div class="topic-metadata">

**Author:** [@Raf](https://discourse.julialang.org/u/Raf)\
**Replies:** 5\
**Last updated:** [November 7, 2019, 9:03pm UTC](https://discourse.julialang.org/t/why-does-map-of-a-named-tuple-and-tuple-return-an-array/30468 "2019-11-07T21:03:21Z")

</div>

Array seems like a strange return type for this interaction: julia\> map(+, (1, 2), (x=1, y=2)) 2-element Array{Int64,1}: 2 4 Why not tuple?

---

## [How to load a collection of image files with Images.jl or ImageView.jl](https://discourse.julialang.org/t/how-to-load-a-collection-of-image-files-with-images-jl-or-imageview-jl/30829)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 4\
**Last updated:** [November 7, 2019, 7:35pm UTC](https://discourse.julialang.org/t/how-to-load-a-collection-of-image-files-with-images-jl-or-imageview-jl/30829 "2019-11-07T19:35:48Z")

</div>

I have generated (in //) a collection of image files : toto1.gif, toto2.gif,…,toto100.gif How can I load and visualize them with ImageView.jl ? Laurent

---

## [Errors parsing when reading STATA file](https://discourse.julialang.org/t/errors-parsing-when-reading-stata-file/30840)

<div class="topic-metadata">

**Author:** [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Replies:** 2\
**Last updated:** [November 7, 2019, 7:11pm UTC](https://discourse.julialang.org/t/errors-parsing-when-reading-stata-file/30840 "2019-11-07T19:11:21Z")

</div>

I am reading a STATA file (likely created in 2014; not known which STATA version was used) and get the following error: using DataFrames \[ Info: Precompiling DataFrames \[a93c6f00-e57d-5684-b7b6-d8193f3e46c0\] julia\> usi…

---

## [PyPlot 3d plotting](https://discourse.julialang.org/t/pyplot-3d-plotting/30838)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 1\
**Last updated:** [November 7, 2019, 7:02pm UTC](https://discourse.julialang.org/t/pyplot-3d-plotting/30838 "2019-11-07T19:02:49Z")

</div>

Why this code does not work without second line: p1=scatter3D(,0) ? This line is unnecessary for me. How to write it correctly to get one chart, not two ? using PyPlot p1=scatter3D(\[\],0) fig = plt.figure() ax = fig.add…

---

## [Switching from 1.1 to 1.2, more startup slowness after loading startup file](https://discourse.julialang.org/t/switching-from-1-1-to-1-2-more-startup-slowness-after-loading-startup-file/30832)

<div class="topic-metadata">

**Author:** [@Usor](https://discourse.julialang.org/u/Usor)\
**Replies:** 4\
**Last updated:** [November 7, 2019, 5:24pm UTC](https://discourse.julialang.org/t/switching-from-1-1-to-1-2-more-startup-slowness-after-loading-startup-file/30832 "2019-11-07T17:24:30Z")

</div>

I understand that there may be some slowness, and I don’t mind it so much, but when I switched from 1.1 to 1.2, Julia became much slower after manually loading a startup file. Though the cursor blinks after loading, pres…

---

## [Initializing an array of mutable objects is surprisingly slow](https://discourse.julialang.org/t/initializing-an-array-of-mutable-objects-is-surprisingly-slow/11780)

<div class="topic-metadata">

**Author:** [@cnliao](https://discourse.julialang.org/u/cnliao)\
**Replies:** 8\
**Last updated:** [November 7, 2019, 3:13pm UTC](https://discourse.julialang.org/t/initializing-an-array-of-mutable-objects-is-surprisingly-slow/11780 "2019-11-07T15:13:57Z")

</div>

How can one performantly preallocate a vector of mutable objects? Currently allocating and initializing a vector of mutables is ~60x slower than doing the same thing for mutables: # same result on v0.6.3 and latest mast…

---

## [Isassigned for blocks in BlockArrays](https://discourse.julialang.org/t/isassigned-for-blocks-in-blockarrays/30831)

<div class="topic-metadata">

**Author:** [@krcools](https://discourse.julialang.org/u/krcools)\
**Replies:** 0\
**Last updated:** [November 7, 2019, 3:12pm UTC](https://discourse.julialang.org/t/isassigned-for-blocks-in-blockarrays/30831 "2019-11-07T15:12:11Z")

</div>

Is there a way to check that a block in a BlockArray is assigned? I would expect syntax like isassigned(A, Block(2,3))

---

## [Iterating using Channel](https://discourse.julialang.org/t/iterating-using-channel/30762)

<div class="topic-metadata">

**Author:** [@marouane1994](https://discourse.julialang.org/u/marouane1994)\
**Replies:** 6\
**Last updated:** [November 7, 2019, 1:49pm UTC](https://discourse.julialang.org/t/iterating-using-channel/30762 "2019-11-07T13:49:00Z")

</div>

i have some problems in replacing the deprecated function produce()with Channel()in this code: function scan\_maker(A) m = JuMP.Model(solver=ClpSolver(PrimalTolerance=1e-3, DualTolerance=1e-3, InfeasibleReturn=1, Pre…

---

## [Is Julia able to export a module as another (aliased) name?](https://discourse.julialang.org/t/is-julia-able-to-export-a-module-as-another-aliased-name/30814)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 1\
**Last updated:** [November 7, 2019, 2:41am UTC](https://discourse.julialang.org/t/is-julia-able-to-export-a-module-as-another-aliased-name/30814 "2019-11-07T02:41:11Z")

</div>

I am not the author of Yao.jl. I just want to use it as an example. The source code of Yao.jl is just one simple thing: reexport things defined in its sub-packages. using Reexport @reexport using YaoBase, YaoArrayRegist…

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

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