# General Usage

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

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

**Page:** 994

---

## [Cannot set a non-diagonal index in a Hermitian matrix](https://discourse.julialang.org/t/cannot-set-a-non-diagonal-index-in-a-hermitian-matrix/9348)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 1\
**Last updated:** [February 26, 2018, 7:43pm UTC](https://discourse.julialang.org/t/cannot-set-a-non-diagonal-index-in-a-hermitian-matrix/9348 "2018-02-26T19:43:07Z")

</div>

Is there a way to set a non-diagonal entry in a Hermitian matrix? For example, if I set H\[i,j\], I’d expect the implementation to automatically set H\[j,i\] as well, to maintain hermiticity.

---

## [How to use the SMTPClient-package](https://discourse.julialang.org/t/how-to-use-the-smtpclient-package/9317)

<div class="topic-metadata">

**Author:** [@johann.spies](https://discourse.julialang.org/u/johann.spies)\
**Replies:** 1\
**Last updated:** [February 26, 2018, 5:17pm UTC](https://discourse.julialang.org/t/how-to-use-the-smtpclient-package/9317 "2018-02-26T17:17:57Z")

</div>

The only example of using the SMTPClient package I could find was on https://rosettacode.org/wiki/Send\_email#Julia. I adapted it a bit to test but gets a segmentation fault on Version 0.6.2: addbrackets(s) = replace(…

---

## [Iteration over collections with unassigned entries](https://discourse.julialang.org/t/iteration-over-collections-with-unassigned-entries/9344)

<div class="topic-metadata">

**Author:** [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Replies:** 1\
**Last updated:** [February 26, 2018, 4:37pm UTC](https://discourse.julialang.org/t/iteration-over-collections-with-unassigned-entries/9344 "2018-02-26T16:37:55Z")

</div>

How does one handle #undef entries in a comprehension over a collection? Say I have julia\> struct Foo v::Vector{Int} end julia\> bar = Vector{Foo}(uninitialized, 3); bar\[1\] = Foo(\[1\]); bar\[3\] = Foo(\[3…

---

## [GitError Pkg.update()](https://discourse.julialang.org/t/giterror-pkg-update/9337)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 2\
**Last updated:** [February 26, 2018, 3:01pm UTC](https://discourse.julialang.org/t/giterror-pkg-update/9337 "2018-02-26T15:01:27Z")

</div>

Version 0.6.2 (2017-12-13 18:08 UTC) x86\_64-w64-mingw32 julia\> Pkg.update() INFO: Initializing package repository C:\\Users\\PC.julia\\v0.6 INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl ERROR: Gi…

---

## [JuliaPro and Julia Simultaneous Installations: Sensible? Conflicts?](https://discourse.julialang.org/t/juliapro-and-julia-simultaneous-installations-sensible-conflicts/9258)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 13\
**Last updated:** [February 26, 2018, 2:46pm UTC](https://discourse.julialang.org/t/juliapro-and-julia-simultaneous-installations-sensible-conflicts/9258 "2018-02-26T14:46:46Z")

</div>

I have the standard julia 0.6.2 already installed. Does it make sense to install both JuliaPro 0.6.2.1, or is it identical to standard Julia but with packages already in the box, plus some extras? if it makes sense…

---

## [Overload call to do multiplication on numbers?](https://discourse.julialang.org/t/overload-call-to-do-multiplication-on-numbers/9279)

<div class="topic-metadata">

**Author:** [@antoine-levitt](https://discourse.julialang.org/u/antoine-levitt)\
**Replies:** 9\
**Last updated:** [February 26, 2018, 2:42pm UTC](https://discourse.julialang.org/t/overload-call-to-do-multiplication-on-numbers/9279 "2018-02-26T14:42:44Z")

</div>

I really like the 2x syntax, and get tired of writing stars. edit: actual example… function (x::Float64)(y) x\*y end a = 2.0 a(2+2) That looks like a hilariously bad idea, but I can’t find any actual problems with …

---

## [Is \`where T\` the same as \`where T \<: Any\` in all cases?](https://discourse.julialang.org/t/is-where-t-the-same-as-where-t-any-in-all-cases/9329)

<div class="topic-metadata">

**Author:** [@jballanc](https://discourse.julialang.org/u/jballanc)\
**Replies:** 8\
**Last updated:** [February 26, 2018, 9:17am UTC](https://discourse.julialang.org/t/is-where-t-the-same-as-where-t-any-in-all-cases/9329 "2018-02-26T09:17:42Z")

</div>

So, my question is pretty straight-forward (and right there entirely in the title), but to give a bit of background/justification… I realize that the function foo(bar::Baz{T}) where T syntax is relatively new, and so so…

---

## [ANN: Setfield.jl Yet another package for working with immutables](https://discourse.julialang.org/t/ann-setfield-jl-yet-another-package-for-working-with-immutables/9267)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 44\
**Last updated:** [February 26, 2018, 8:32am UTC](https://discourse.julialang.org/t/ann-setfield-jl-yet-another-package-for-working-with-immutables/9267 "2018-02-26T08:32:18Z")

</div>

Setfield.jl is a package for modifying immutables. It allows to write code like @set obj.a.b.c = foo which yields a duplicate of obj with the appropriate field replaced. Compared to Reconstructables.jl it has the follo…

---

## [Field overloading to flatten struct composition?](https://discourse.julialang.org/t/field-overloading-to-flatten-struct-composition/9325)

<div class="topic-metadata">

**Author:** [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Replies:** 1\
**Last updated:** [February 26, 2018, 6:40am UTC](https://discourse.julialang.org/t/field-overloading-to-flatten-struct-composition/9325 "2018-02-26T06:40:52Z")

</div>

I was wondering whether composite type field overloading (introduced in 0.7) could be used to “flatten” access to composed data structures. There has been much discussion about inheritance vs composition, and I was hopin…

---

## [Parallelizing for loop in the computation of a gradient](https://discourse.julialang.org/t/parallelizing-for-loop-in-the-computation-of-a-gradient/9154)

<div class="topic-metadata">

**Author:** [@kmundnic](https://discourse.julialang.org/u/kmundnic)\
**Replies:** 19\
**Last updated:** [February 26, 2018, 1:06am UTC](https://discourse.julialang.org/t/parallelizing-for-loop-in-the-computation-of-a-gradient/9154 "2018-02-26T01:06:43Z")

</div>

I’ve ported some code from a Cython implementation that may be found here into Julia. This code is parallelized and currently runs ~0.4x faster on my machine compared to my best Julia implementation. The function that i…

---

## [Boilerplate code generation by evaluation of parsed strings](https://discourse.julialang.org/t/boilerplate-code-generation-by-evaluation-of-parsed-strings/9326)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 4\
**Last updated:** [February 26, 2018, 1:03am UTC](https://discourse.julialang.org/t/boilerplate-code-generation-by-evaluation-of-parsed-strings/9326 "2018-02-26T01:03:08Z")

</div>

Hi all, The following is a trivial MWE of something I find myself doing sometimes in my code: I define some new struct struct M x::Float64 y::String end and I want to build accessor functions for getting the f…

---

## [Cmd vs String](https://discourse.julialang.org/t/cmd-vs-string/9318)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 2\
**Last updated:** [February 25, 2018, 7:29pm UTC](https://discourse.julialang.org/t/cmd-vs-string/9318 "2018-02-25T19:29:23Z")

</div>

dear julia experts—I am trying to understand why julia avoids strings as arguments for run and readall. WIth Cmd and run and readall, it can require some effort construct pipelines, too. Then there is the fact that it …

---

## [Non-existing writeall() reference in Docs](https://discourse.julialang.org/t/non-existing-writeall-reference-in-docs/9321)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 0\
**Last updated:** [February 25, 2018, 6:32pm UTC](https://discourse.julialang.org/t/non-existing-writeall-reference-in-docs/9321 "2018-02-25T18:32:25Z")

</div>

dear julia experts: https://github.com/JuliaLang/julia/issues/18834 writeall still referenced in ‘Avoiding Deadlock in Pipelines’ in the stable docs. I was looking for a way to have my julia program pass information t…

---

## [Tree structure with parametric type](https://discourse.julialang.org/t/tree-structure-with-parametric-type/9300)

<div class="topic-metadata">

**Author:** [@maxtremblay](https://discourse.julialang.org/u/maxtremblay)\
**Replies:** 4\
**Last updated:** [February 25, 2018, 6:04pm UTC](https://discourse.julialang.org/t/tree-structure-with-parametric-type/9300 "2018-02-25T18:04:34Z")

</div>

Hello, I want to build a tree from abstract type ABC end struct A{x \<: ABC} \<: ABC a::Vector{x} end struct B \<: ABC a::Vector{Float64} end Then I can build the two first layers like this low1 = \[B(\[0.1, 0.2…

---

## [Understanding memory model for multi-threading](https://discourse.julialang.org/t/understanding-memory-model-for-multi-threading/9306)

<div class="topic-metadata">

**Author:** [@rasmus](https://discourse.julialang.org/u/rasmus)\
**Replies:** 3\
**Last updated:** [February 25, 2018, 4:26pm UTC](https://discourse.julialang.org/t/understanding-memory-model-for-multi-threading/9306 "2018-02-25T16:26:24Z")

</div>

Hi, I’ve been reading about and experimenting with multi-threading in Julia (https://docs.julialang.org/en/latest/manual/parallel-computing/, and https://docs.julialang.org/en/latest/base/multi-threading/). When using …

---

## [Difference in allocations when constructing array-of-arrays vs array-of-structs](https://discourse.julialang.org/t/difference-in-allocations-when-constructing-array-of-arrays-vs-array-of-structs/9323)

<div class="topic-metadata">

**Author:** [@piever](https://discourse.julialang.org/u/piever)\
**Replies:** 5\
**Last updated:** [February 25, 2018, 3:12pm UTC](https://discourse.julialang.org/t/difference-in-allocations-when-constructing-array-of-arrays-vs-array-of-structs/9323 "2018-02-25T15:12:10Z")

</div>

I have a similar question concerning a very different use cases: the case where most of the inner vectors are actually equal and pretty large (for example, useful when working with “shifted versions” of the same Array, t…

---

## [Function and gradient evaluation in same function Ipopt](https://discourse.julialang.org/t/function-and-gradient-evaluation-in-same-function-ipopt/9311)

<div class="topic-metadata">

**Author:** [@mopg](https://discourse.julialang.org/u/mopg)\
**Replies:** 2\
**Last updated:** [February 25, 2018, 1:57pm UTC](https://discourse.julialang.org/t/function-and-gradient-evaluation-in-same-function-ipopt/9311 "2018-02-25T13:57:36Z")

</div>

I am using Ipopt.jl as my optimizer and would like to compute the function value and its gradient in the same Julia function (for performance reasons). See this example: https://github.com/JuliaOpt/Ipopt.jl/blob/master/…

---

## [Run a subprocess in a pseudo terminal](https://discourse.julialang.org/t/run-a-subprocess-in-a-pseudo-terminal/9294)

<div class="topic-metadata">

**Author:** [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Replies:** 4\
**Last updated:** [February 25, 2018, 12:45pm UTC](https://discourse.julialang.org/t/run-a-subprocess-in-a-pseudo-terminal/9294 "2018-02-25T12:45:58Z")

</div>

I am trying to build a small script which would initiate workers on PBS cluster through interactive job. For that I need a way to execute cat $PBS\_NODEFILE in interactive session to get associated resources to me. Essent…

---

## [Method chaining with arguments to imitate unix piping?](https://discourse.julialang.org/t/method-chaining-with-arguments-to-imitate-unix-piping/9308)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 2\
**Last updated:** [February 25, 2018, 7:20am UTC](https://discourse.julialang.org/t/method-chaining-with-arguments-to-imitate-unix-piping/9308 "2018-02-25T07:20:59Z")

</div>

dear julia experts: I am trying to understand method chaining. I believe that instead of f(g(x)), this means I can use g(x) |\> f(). Can one do more than this? Say, I have defined julia\> grep(heystack,needle) = fil…

---

## [How to get a pointer Ptr{T} that references a variable of type T](https://discourse.julialang.org/t/how-to-get-a-pointer-ptr-t-that-references-a-variable-of-type-t/9273)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 9\
**Last updated:** [February 25, 2018, 7:13am UTC](https://discourse.julialang.org/t/how-to-get-a-pointer-ptr-t-that-references-a-variable-of-type-t/9273 "2018-02-25T07:13:16Z")

</div>

I need to pass a Ptr{T} to a C function but pointer\_from\_objref returns Ptr{Void} rather than Ptr{T}… How should I do this? In the following example, I need to pass a value of type Ptr{Foo} to the C function: julia\> st…

---

## [The new output of findfirst is dangerous](https://discourse.julialang.org/t/the-new-output-of-findfirst-is-dangerous/9131)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 20\
**Last updated:** [February 24, 2018, 9:05pm UTC](https://discourse.julialang.org/t/the-new-output-of-findfirst-is-dangerous/9131 "2018-02-24T21:05:08Z")

</div>

Because findfirst can output a boolean a notthing or an iterator and in this later case, an 0:-1 when it finds nothing. See this example julia\> first(findfirst(fieldnames(GMT.GMTgrid), :z)) ┌ Warning: \`findfirst(A, v)\`…

---

## [DateTime: high resolution treatment of time with Julia](https://discourse.julialang.org/t/datetime-high-resolution-treatment-of-time-with-julia/9302)

<div class="topic-metadata">

**Author:** [@Steven\_Varga](https://discourse.julialang.org/u/Steven_Varga)\
**Replies:** 0\
**Last updated:** [February 24, 2018, 7:32pm UTC](https://discourse.julialang.org/t/datetime-high-resolution-treatment-of-time-with-julia/9302 "2018-02-24T19:32:52Z")

</div>

For some reasons I fail to use Datetime correctly, can someone point out what I am doing wrong? C++11 clock provides a time\_point, representation (short,long, float, … ) with duration from a given epoch with some pro…

---

## [Parametric constructor](https://discourse.julialang.org/t/parametric-constructor/9290)

<div class="topic-metadata">

**Author:** [@Snir\_Gazit](https://discourse.julialang.org/u/Snir_Gazit)\
**Replies:** 5\
**Last updated:** [February 24, 2018, 6:02pm UTC](https://discourse.julialang.org/t/parametric-constructor/9290 "2018-02-24T18:02:34Z")

</div>

I am defining the data structure below, which contains a string and a parameterized type array. I’m having trouble defining the corresponding parameterized constructor that initializes a zero-length array of the requeste…

---

## [Can't build FFTW.jl](https://discourse.julialang.org/t/cant-build-fftw-jl/9295)

<div class="topic-metadata">

**Author:** [@navidcy](https://discourse.julialang.org/u/navidcy)\
**Replies:** 0\
**Last updated:** [February 24, 2018, 3:40pm UTC](https://discourse.julialang.org/t/cant-build-fftw-jl/9295 "2018-02-24T15:40:05Z")

</div>

I’m having trouble building FFTW.jl julia\> Pkg.build("FFTW") \[ Info: Building FFTW ┌ Warning: \`replace(s::AbstractString, pat, f)\` is deprecated, use \`replace(s, pat =\> f)\` instead. │ caller = makealiases(::String) at…

---

## [Why does \`reinterpret\` cause an extra allocation?](https://discourse.julialang.org/t/why-does-reinterpret-cause-an-extra-allocation/8833)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 30\
**Last updated:** [February 24, 2018, 2:12pm UTC](https://discourse.julialang.org/t/why-does-reinterpret-cause-an-extra-allocation/8833 "2018-02-24T14:12:06Z")

</div>

Hello all. I’ve recently taken to removing pointers from some code and investigating whether there is anything which would not be possible to do efficiently in Julia without them. First exhibit, the behavior of reinter…

---

## [Something missing in Missings](https://discourse.julialang.org/t/something-missing-in-missings/9242)

<div class="topic-metadata">

**Author:** [@ivo\_welch](https://discourse.julialang.org/u/ivo_welch)\
**Replies:** 10\
**Last updated:** [February 23, 2018, 5:21pm UTC](https://discourse.julialang.org/t/something-missing-in-missings/9242 "2018-02-23T17:21:16Z")

</div>

I think an update has just hosed Missings. On my system, stuff that I recalled having worked yesterday no longer seems to work. on JuliaPro 0.6.2.1: julia\> using Missings; INFO: Precompiling module Missings. ERROR: Lo…

---

## [Most efficient way of converting binary data to \`AbstractVector{Bool}\`](https://discourse.julialang.org/t/most-efficient-way-of-converting-binary-data-to-abstractvector-bool/9261)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 4\
**Last updated:** [February 23, 2018, 4:06pm UTC](https://discourse.julialang.org/t/most-efficient-way-of-converting-binary-data-to-abstractvector-bool/9261 "2018-02-23T16:06:54Z")

</div>

Suppose I have a Vector{\<:Unsigned} and I want to convert the bits to some sort of AbstractVector{Bool}. I want to know the absolute most efficient way of doing that (I don’t even really care what kind of object I conve…

---

## [Pkg.update error, Base.LibGit2 test fails](https://discourse.julialang.org/t/pkg-update-error-base-libgit2-test-fails/9272)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 12\
**Last updated:** [February 23, 2018, 3:29pm UTC](https://discourse.julialang.org/t/pkg-update-error-base-libgit2-test-fails/9272 "2018-02-23T15:29:09Z")

</div>

I got the following error when I tried to update the packages. I use Pkg.checkout(“CSV”) to get the latest version of CSV.jl. Today, I called Pkg.free(“CSV”). After doing this, I cannot update the packages. (Window 7…

---

## [mangled error message when re-throwing exceptions](https://discourse.julialang.org/t/mangled-error-message-when-re-throwing-exceptions/9253)

<div class="topic-metadata">

**Author:** [@mkaut](https://discourse.julialang.org/u/mkaut)\
**Replies:** 4\
**Last updated:** [February 23, 2018, 8:05am UTC](https://discourse.julialang.org/t/mangled-error-message-when-re-throwing-exceptions/9253 "2018-02-23T08:05:28Z")

</div>

Consider this simple example: function failme() error("failme() failed") end function test() try failme() catch err error("error in test(): $err") end end function main() try test() catch err println("er…

---

## [How to adjust the size of markers in legend box?](https://discourse.julialang.org/t/how-to-adjust-the-size-of-markers-in-legend-box/9271)

<div class="topic-metadata">

**Author:** [@zolamusic](https://discourse.julialang.org/u/zolamusic)\
**Replies:** 0\
**Last updated:** [February 23, 2018, 2:02am UTC](https://discourse.julialang.org/t/how-to-adjust-the-size-of-markers-in-legend-box/9271 "2018-02-23T02:02:52Z")

</div>

When I change the marker size, it works well. However, it does not change the size of markers in the legend box. plot( xs, ys, titlefont = font("Times new roman", 32), tickfont = font("Times new r…

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

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