# General Usage

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

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

**Page:** 888

---

## [String changed behaviour in Julia 1.1](https://discourse.julialang.org/t/string-changed-behaviour-in-julia-1-1/21561)

<div class="topic-metadata">

**Author:** [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Replies:** 3\
**Last updated:** [March 7, 2019, 10:02am UTC](https://discourse.julialang.org/t/string-changed-behaviour-in-julia-1-1/21561 "2019-03-07T10:02:23Z")

</div>

string(String\[\]) seems to be a no-op in Julia 1.1. In 1.0.3. this worked as intended for me (see below). Was this change intentional? Note that string.(String\[\])!=string(String\[\]) in v1.0.3 It is breaking some code o…

---

## [Unbounded IterativeSolvers.Gmres! different output to MATLAB, slows convergence significantly](https://discourse.julialang.org/t/unbounded-iterativesolvers-gmres-different-output-to-matlab-slows-convergence-significantly/21499)

<div class="topic-metadata">

**Author:** [@timmm](https://discourse.julialang.org/u/timmm)\
**Replies:** 13\
**Last updated:** [March 7, 2019, 9:06am UTC](https://discourse.julialang.org/t/unbounded-iterativesolvers-gmres-different-output-to-matlab-slows-convergence-significantly/21499 "2019-03-07T09:06:55Z")

</div>

Hi all, For project here: GitHub - Timmmdavis/FischerNewton: Julia version of NUM4LCP.m I am having issues with the results of IterativeSolvers.Gmres! The main code is under: FischerNewton/src/fischer\_newton.jl If I ad…

---

## [Matrix storage in julia](https://discourse.julialang.org/t/matrix-storage-in-julia/21015)

<div class="topic-metadata">

**Author:** [@Suraj\_Pawar](https://discourse.julialang.org/u/Suraj_Pawar)\
**Replies:** 8\
**Last updated:** [March 7, 2019, 12:49am UTC](https://discourse.julialang.org/t/matrix-storage-in-julia/21015 "2019-03-07T00:49:02Z")

</div>

How is the matrix stored in Julia? Is it row-major storage like in C++ or column-major storage like Fortran? Recently, I converted my Fortran code in Julia. In Fortran, it takes around 1.6 seconds to run the program. In …

---

## [Automatic parallelization/ multithreading](https://discourse.julialang.org/t/automatic-parallelization-multithreading/21028)

<div class="topic-metadata">

**Author:** [@Suraj\_Pawar](https://discourse.julialang.org/u/Suraj_Pawar)\
**Replies:** 3\
**Last updated:** [March 6, 2019, 11:43pm UTC](https://discourse.julialang.org/t/automatic-parallelization-multithreading/21028 "2019-03-06T23:43:17Z")

</div>

Does Julia do automatic multithreading or parallelization if it is possible? For example, I have code in Fortran and in Julia. For a smaller problem, I get faster performance in Fortran. But as I increase the problem siz…

---

## [CuArrays and garbage collection when doing FFT convolutions](https://discourse.julialang.org/t/cuarrays-and-garbage-collection-when-doing-fft-convolutions/12412)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 12\
**Last updated:** [March 6, 2019, 8:39pm UTC](https://discourse.julialang.org/t/cuarrays-and-garbage-collection-when-doing-fft-convolutions/12412 "2019-03-06T20:39:01Z")

</div>

Hi, I am using CuArrays to perform fft convolutions and I am getting the error ERROR: CUFFTError(code 2, cuFFT failed to allocate GPU or CPU memory). I have threads about collecting temporaries but I don’t know how to…

---

## [Use of @code\_warntype on a function with keyword arguments](https://discourse.julialang.org/t/use-of-code-warntype-on-a-function-with-keyword-arguments/5521)

<div class="topic-metadata">

**Author:** [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)\
**Replies:** 5\
**Last updated:** [March 6, 2019, 7:14pm UTC](https://discourse.julialang.org/t/use-of-code-warntype-on-a-function-with-keyword-arguments/5521 "2019-03-06T19:14:01Z")

</div>

I would like to use @code\_warntype on a function with a keyword argument. Consider the following simple example with an intentional type instability: function myfun(a; tol = 2) x = (a \> 42 ? a : 42.) return x + t…

---

## [Where to find profiling (.mem/.cov) files](https://discourse.julialang.org/t/where-to-find-profiling-mem-cov-files/21200)

<div class="topic-metadata">

**Author:** [@dhazeghi](https://discourse.julialang.org/u/dhazeghi)\
**Replies:** 1\
**Last updated:** [March 6, 2019, 4:16pm UTC](https://discourse.julialang.org/t/where-to-find-profiling-mem-cov-files/21200 "2019-03-06T16:16:32Z")

</div>

Hi folks, I’m trying to do analysis on some code using the --track-allocation=user and --code-coverage=user. Profiling data does seem to be getting saved for external packages (e.g. Base, DataFrames, etc.) in the packa…

---

## [How to create a sparse matrix obeying (-1,1) uniform distribution](https://discourse.julialang.org/t/how-to-create-a-sparse-matrix-obeying-1-1-uniform-distribution/21527)

<div class="topic-metadata">

**Author:** [@xieximeng2008](https://discourse.julialang.org/u/xieximeng2008)\
**Replies:** 1\
**Last updated:** [March 6, 2019, 3:36pm UTC](https://discourse.julialang.org/t/how-to-create-a-sparse-matrix-obeying-1-1-uniform-distribution/21527 "2019-03-06T15:36:15Z")

</div>

I try to code using SparseArrays using Distributions sprandn(100,100,0.3,Uniform(-1,1)) But it failed. So how to generate a sparse matrix obeying (-1,1) uniform distribution? Thanks

---

## [Recursive fallback methods error message](https://discourse.julialang.org/t/recursive-fallback-methods-error-message/21534)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [March 6, 2019, 3:25pm UTC](https://discourse.julialang.org/t/recursive-fallback-methods-error-message/21534 "2019-03-06T15:25:01Z")

</div>

I have an interface which exposes some functions, let’s call them f and g here for the MWE. The user is expected to define methods for user-defined types. But it is sufficient to define one of them, as the other can be …

---

## [Version and repo-rev Pkg Manager](https://discourse.julialang.org/t/version-and-repo-rev-pkg-manager/21497)

<div class="topic-metadata">

**Author:** [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Replies:** 4\
**Last updated:** [March 6, 2019, 2:13pm UTC](https://discourse.julialang.org/t/version-and-repo-rev-pkg-manager/21497 "2019-03-06T14:13:41Z")

</div>

Can someone explain the difference between ‘repo-rev’ and ‘version’? I tried to pin a package by doing \]rm DataFrames \]add DataFrames@0.14.1 \]pin DataFrames@0.14.1 This did not work as expected. It resulted in the man…

---

## [Space after quoted field breaks delimited file parsing](https://discourse.julialang.org/t/space-after-quoted-field-breaks-delimited-file-parsing/21531)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 2\
**Last updated:** [March 6, 2019, 11:28am UTC](https://discourse.julialang.org/t/space-after-quoted-field-breaks-delimited-file-parsing/21531 "2019-03-06T11:28:36Z")

</div>

DelimitedFiles can not parse a file that has an extra space after a quoted field: txt = "a,\\"b\\" " # note the extra space at the end there file = "tmp.csv" open(file, "w") do io print(io, txt) end using DelimitedFi…

---

## [Transforming a function into a sequence of mutable operations on objects](https://discourse.julialang.org/t/transforming-a-function-into-a-sequence-of-mutable-operations-on-objects/21508)

<div class="topic-metadata">

**Author:** [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Replies:** 5\
**Last updated:** [March 6, 2019, 11:15am UTC](https://discourse.julialang.org/t/transforming-a-function-into-a-sequence-of-mutable-operations-on-objects/21508 "2019-03-06T11:15:05Z")

</div>

The following example comes up in the Taylor method for integrating differential equations, but the question keeps coming up over and over again. Suppose I have something like the following, which is over-simplified, in…

---

## [Deprecate method of extended function](https://discourse.julialang.org/t/deprecate-method-of-extended-function/21491)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 2\
**Last updated:** [March 5, 2019, 2:59pm UTC](https://discourse.julialang.org/t/deprecate-method-of-extended-function/21491 "2019-03-05T14:59:56Z")

</div>

Say I have the following dummy module module MyModule struct MyType end Base.length(m::MyType) = 5 export length end What I want to do is @deprecate the length function in favor of a different function, say mylengt…

---

## [Repeating (with function repeat) array elements using a vector of numbers](https://discourse.julialang.org/t/repeating-with-function-repeat-array-elements-using-a-vector-of-numbers/21435)

<div class="topic-metadata">

**Author:** [@keeler](https://discourse.julialang.org/u/keeler)\
**Replies:** 13\
**Last updated:** [March 5, 2019, 2:40pm UTC](https://discourse.julialang.org/t/repeating-with-function-repeat-array-elements-using-a-vector-of-numbers/21435 "2019-03-05T14:40:50Z")

</div>

I would like to take a vector, x, and create a new vector, y, by repeating each element in x a number of times, where each number is an element of another vector v. For example: x=\[0.1; 0.6; 0.5\]; v=\[3; 1; 2\]; then the …

---

## [Creating Julia function from a symbolic expression (using SymEngine)](https://discourse.julialang.org/t/creating-julia-function-from-a-symbolic-expression-using-symengine/21476)

<div class="topic-metadata">

**Author:** [@fedxa](https://discourse.julialang.org/u/fedxa)\
**Replies:** 6\
**Last updated:** [March 5, 2019, 9:09am UTC](https://discourse.julialang.org/t/creating-julia-function-from-a-symbolic-expression-using-symengine/21476 "2019-03-05T09:09:13Z")

</div>

Hello, what would be a good way to define a Julia function based on the result of symbolic calculations? For the moment, using lambdify in SymEngine gives a rather slow result, as compared to “brute force” parsing of th…

---

## [Capacitated Vehicle Routing Problem: Subtour Eliminiation ](https://discourse.julialang.org/t/capacitated-vehicle-routing-problem-subtour-eliminiation/21483)

<div class="topic-metadata">

**Author:** [@vikas9087](https://discourse.julialang.org/u/vikas9087)\
**Replies:** 1\
**Last updated:** [March 5, 2019, 6:25am UTC](https://discourse.julialang.org/t/capacitated-vehicle-routing-problem-subtour-eliminiation/21483 "2019-03-05T06:25:58Z")

</div>

Hi All, I have a vehicle routing problem with the capacity of a vehicle. I have solved the problem, but I am facing with subtours b/w distribution center and customers. I have eliminated most of the subtours by using no…

---

## [Base.replace issue with type promotion](https://discourse.julialang.org/t/base-replace-issue-with-type-promotion/21484)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 1\
**Last updated:** [March 5, 2019, 4:53am UTC](https://discourse.julialang.org/t/base-replace-issue-with-type-promotion/21484 "2019-03-05T04:53:46Z")

</div>

If I pass a function to replace then it doesn’t seem to promote the type of the vector. julia\> x = rand(\[nothing, 1,2,3\], 10000); julia\> foo(v) = replace(x -\> x === nothing ? missing : x, v) foo (generic function with …

---

## [Error sending packages to other workers (parallelization)](https://discourse.julialang.org/t/error-sending-packages-to-other-workers-parallelization/19851)

<div class="topic-metadata">

**Author:** [@juliauser](https://discourse.julialang.org/u/juliauser)\
**Replies:** 6\
**Last updated:** [March 4, 2019, 6:04pm UTC](https://discourse.julialang.org/t/error-sending-packages-to-other-workers-parallelization/19851 "2019-03-04T18:04:03Z")

</div>

Hi, In previous versions of julia I used to run using Distributed addprocs(3) @everywhere using Distributions where Distributions is just one example of a package. Now I get this error On worker 2: ArgumentError: …

---

## [Large Matrix Takes Forever](https://discourse.julialang.org/t/large-matrix-takes-forever/21328)

<div class="topic-metadata">

**Author:** [@olabaz](https://discourse.julialang.org/u/olabaz)\
**Replies:** 4\
**Last updated:** [March 4, 2019, 5:06pm UTC](https://discourse.julialang.org/t/large-matrix-takes-forever/21328 "2019-03-04T17:06:01Z")

</div>

Hi, I am new to Julia and I am writing a program that makes a random matrix drawn from the Haar distribution. It works fine for small matrices ~200x200 but when I try for 1000x1000 the program takes a very long time to r…

---

## [Error "no method matching fieldindex"](https://discourse.julialang.org/t/error-no-method-matching-fieldindex/21468)

<div class="topic-metadata">

**Author:** [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Replies:** 1\
**Last updated:** [March 4, 2019, 4:57pm UTC](https://discourse.julialang.org/t/error-no-method-matching-fieldindex/21468 "2019-03-04T16:57:02Z")

</div>

Since Random123 was moved into a separate package (at least I think), some fairly involved code that ran fine before now throws an ERROR: MethodError: no method matching fieldindex(::Type{Random123.Philox4x}, ::Symbol, …

---

## [Strange bug(Segmentation fault: 11) solely existed in julia v1.0](https://discourse.julialang.org/t/strange-bug-segmentation-fault-11-solely-existed-in-julia-v1-0/21392)

<div class="topic-metadata">

**Author:** [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Replies:** 2\
**Last updated:** [March 4, 2019, 9:51am UTC](https://discourse.julialang.org/t/strange-bug-segmentation-fault-11-solely-existed-in-julia-v1-0/21392 "2019-03-04T09:51:41Z")

</div>

Firstly, the codes run well in v1.1 and nightly version. When it comes to CI in v1.0, there is a strange phenomenon: It firstly appeared when a project requires both DataFrames.jl and MLStyle.jl in Julia v1.0, but a…

---

## [Is there a fixed-length array list with support for push/pop'ing from start?](https://discourse.julialang.org/t/is-there-a-fixed-length-array-list-with-support-for-push-poping-from-start/21434)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 3\
**Last updated:** [March 3, 2019, 10:56pm UTC](https://discourse.julialang.org/t/is-there-a-fixed-length-array-list-with-support-for-push-poping-from-start/21434 "2019-03-03T22:56:38Z")

</div>

The idea is that: N = 4 cur\_array\_1 = zeros(N) is fast, but pushing/popping will start at the end \> push!(cur\_array\_1, 1) \[ 0 0 0 0 1 \] A more useful data structure would then be an array list: cur\_array\_2 = \[\] \> …

---

## [What do @inbounds and @inline do?](https://discourse.julialang.org/t/what-do-inbounds-and-inline-do/21432)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 2\
**Last updated:** [March 3, 2019, 10:38pm UTC](https://discourse.julialang.org/t/what-do-inbounds-and-inline-do/21432 "2019-03-03T22:38:29Z")

</div>

These two macros – @inbounds and @inline – get thrown around a lot when performance comes up. What exactly do they do? When should you use them? When should you not use them? Also, are there other useful performance m…

---

## [Is there a lazy sparse matrix constructor?](https://discourse.julialang.org/t/is-there-a-lazy-sparse-matrix-constructor/21422)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 3\
**Last updated:** [March 3, 2019, 9:54pm UTC](https://discourse.julialang.org/t/is-there-a-lazy-sparse-matrix-constructor/21422 "2019-03-03T21:54:48Z")

</div>

Constructing a sparse matrix via the following is slow: n = 200 m = 250 A = spzeros(n,m) for i in 1:n for j in 1:m A\[i,j\] = rand() end end The way to speed this up is to use the following syntax: cur\_I = Int…

---

## [Fastest way to index matrices](https://discourse.julialang.org/t/fastest-way-to-index-matrices/21429)

<div class="topic-metadata">

**Author:** [@Donald\_Williams](https://discourse.julialang.org/u/Donald_Williams)\
**Replies:** 6\
**Last updated:** [March 3, 2019, 8:49pm UTC](https://discourse.julialang.org/t/fastest-way-to-index-matrices/21429 "2019-03-03T20:49:19Z")

</div>

I am wondering best practices for indexing matrices in Julia. The following seems less than ideal, but struggling to find a good way to do, e.g., cor\_mat\[ - j, -j\], as most examples are cor\_mat\[ j , j \] online. Note tha…

---

## [Memory layout of structs with mutable fields](https://discourse.julialang.org/t/memory-layout-of-structs-with-mutable-fields/21400)

<div class="topic-metadata">

**Author:** [@louisponet](https://discourse.julialang.org/u/louisponet)\
**Replies:** 42\
**Last updated:** [March 3, 2019, 7:41pm UTC](https://discourse.julialang.org/t/memory-layout-of-structs-with-mutable-fields/21400 "2019-03-03T19:41:17Z")

</div>

Hello, I had a question about memory layout of structs that contain mutable fields. e.g. struct Test{Float64} id :: Int data::Vector{Float64} end testarr = \[Test(1, \[2.1,\]), Test(2, \[3.1,\])\] pointer(testarr, 2)…

---

## [Making a Package, 2 questions](https://discourse.julialang.org/t/making-a-package-2-questions/21122)

<div class="topic-metadata">

**Author:** [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Replies:** 8\
**Last updated:** [March 3, 2019, 5:38pm UTC](https://discourse.julialang.org/t/making-a-package-2-questions/21122 "2019-03-03T17:38:42Z")

</div>

Hi everyone, In my spare time I’ve been working on a package in Julia for Chemometrics (GitHub - caseykneale/ChemometricsTools.jl: A collection of tools for chemometrics and machine learning written in Julia. ). It’s ba…

---

## [Single variable least absolute deviation (LAD) linear regression](https://discourse.julialang.org/t/single-variable-least-absolute-deviation-lad-linear-regression/21386)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Replies:** 9\
**Last updated:** [March 3, 2019, 11:19am UTC](https://discourse.julialang.org/t/single-variable-least-absolute-deviation-lad-linear-regression/21386 "2019-03-03T11:19:47Z")

</div>

I’m looking for a simple to use single variable least absolute deviation linear regression library. My problem is modeled by a single variable function with small set (less than 32) of observations. I want to get a linea…

---

## [Nested ForwardDiff.jacobian calls with inplace function](https://discourse.julialang.org/t/nested-forwarddiff-jacobian-calls-with-inplace-function/21232)

<div class="topic-metadata">

**Author:** [@Magalame](https://discourse.julialang.org/u/Magalame)\
**Replies:** 6\
**Last updated:** [March 3, 2019, 3:50am UTC](https://discourse.julialang.org/t/nested-forwarddiff-jacobian-calls-with-inplace-function/21232 "2019-03-03T03:50:52Z")

</div>

I’m trying to compute the jacobian of a jacobian thanks to ForwardDiff. It works perfectly for a non inplace function, but for some reason that evades me, it breaks when the function to differentiate is inplace: using F…

---

## [FFTW won't precompile](https://discourse.julialang.org/t/fftw-wont-precompile/21414)

<div class="topic-metadata">

**Author:** [@harshbarger](https://discourse.julialang.org/u/harshbarger)\
**Replies:** 0\
**Last updated:** [March 3, 2019, 3:25am UTC](https://discourse.julialang.org/t/fftw-wont-precompile/21414 "2019-03-03T03:25:15Z")

</div>

I just want to load an image and access its array data, but it seems that the ImageMagick and Images packages are both dead in the water because the FFTW dependency fails to precompile. I’ve tried letting the Images pack…

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

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