# General Usage

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

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

**Page:** 903

---

## [Cartesian Index Inequalities](https://discourse.julialang.org/t/cartesian-index-inequalities/19644)

<div class="topic-metadata">

**Author:** [@jbmuir](https://discourse.julialang.org/u/jbmuir)\
**Replies:** 8\
**Last updated:** [January 15, 2019, 5:01pm UTC](https://discourse.julialang.org/t/cartesian-index-inequalities/19644 "2019-01-15T17:01:35Z")

</div>

I’m finding the behaviour of comparison for CartesianIndex(s) very confusing; e.g. CartesianIndex(1,1) \<= CartesianIndex(2,0) false CartesianIndex(1,1) \<= CartesianIndex(0,2) true I don’t have a good intuitive reas…

---

## [Save access to vector elements in struct](https://discourse.julialang.org/t/save-access-to-vector-elements-in-struct/19655)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 5\
**Last updated:** [January 15, 2019, 4:40pm UTC](https://discourse.julialang.org/t/save-access-to-vector-elements-in-struct/19655 "2019-01-15T16:40:28Z")

</div>

I’d like to have some values in an array: v = SVector{4, Float64}(rand(4)...) and I want to modify (add) each element in an iterative process. But the modification occurs “somewhere else”: right now, those 4 values are…

---

## [FFT in Julia \> 0.6.3](https://discourse.julialang.org/t/fft-in-julia-0-6-3/19661)

<div class="topic-metadata">

**Author:** [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Replies:** 2\
**Last updated:** [January 15, 2019, 3:18pm UTC](https://discourse.julialang.org/t/fft-in-julia-0-6-3/19661 "2019-01-15T15:18:00Z")

</div>

Hi, I know this is a stupid question but I need to do some FFT in my programs recently and I don’t seem to be able to find the right documentation about the instructions I can use, and working examples on the syntax. Ca…

---

## [How to use a type wrapping a Symbol as a type parameter?](https://discourse.julialang.org/t/how-to-use-a-type-wrapping-a-symbol-as-a-type-parameter/19628)

<div class="topic-metadata">

**Author:** [@Mason](https://discourse.julialang.org/u/Mason)\
**Replies:** 7\
**Last updated:** [January 15, 2019, 7:02am UTC](https://discourse.julialang.org/t/how-to-use-a-type-wrapping-a-symbol-as-a-type-parameter/19628 "2019-01-15T07:02:21Z")

</div>

This question has some lengthy background where I explain my understanding of the problem. If you already know how the rules Julia uses for using values inside type parameters you can skip to the end: My understanding …

---

## [Finding multiplicative inverse modulo n](https://discourse.julialang.org/t/finding-multiplicative-inverse-modulo-n/19603)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 7\
**Last updated:** [January 14, 2019, 10:58pm UTC](https://discourse.julialang.org/t/finding-multiplicative-inverse-modulo-n/19603 "2019-01-14T22:58:33Z")

</div>

Does anyone know of a package that has implemented fast algorithms for finding multiplication inverses modulo n? E.g. 3\*5 = 15 == 1 (mod 7) and hence 3 and 5 are inverses modulo 7. I looked at AbstractAlgebra and it d…

---

## [Eigen solution of Matrix{Rational{BigInt}}](https://discourse.julialang.org/t/eigen-solution-of-matrix-rational-bigint/19627)

<div class="topic-metadata">

**Author:** [@fgerick](https://discourse.julialang.org/u/fgerick)\
**Replies:** 4\
**Last updated:** [January 14, 2019, 9:56pm UTC](https://discourse.julialang.org/t/eigen-solution-of-matrix-rational-bigint/19627 "2019-01-14T21:56:18Z")

</div>

Is there already a way to get eigenvalues and eigenvectors with BigInt/BigFloat accuracy? I know about the GenericLinearAlgebra.jl implementation for eigvals, but I need the high accuracy in the eigenvectors. Anybody kno…

---

## [.julia folder in dropbox](https://discourse.julialang.org/t/julia-folder-in-dropbox/19523)

<div class="topic-metadata">

**Author:** [@matthieu](https://discourse.julialang.org/u/matthieu)\
**Replies:** 3\
**Last updated:** [January 14, 2019, 8:54pm UTC](https://discourse.julialang.org/t/julia-folder-in-dropbox/19523 "2019-01-14T20:54:35Z")

</div>

Is it a good idea to put the .julia folder in a dropbox folder, so that it syncs across all my computers, or would it lead to subtle bugs?

---

## [Help understanding failed optimization when defining Base.similar for AbstractArray interface](https://discourse.julialang.org/t/help-understanding-failed-optimization-when-defining-base-similar-for-abstractarray-interface/19625)

<div class="topic-metadata">

**Author:** [@raminammour](https://discourse.julialang.org/u/raminammour)\
**Replies:** 1\
**Last updated:** [January 14, 2019, 5:00pm UTC](https://discourse.julialang.org/t/help-understanding-failed-optimization-when-defining-base-similar-for-abstractarray-interface/19625 "2019-01-14T17:00:31Z")

</div>

Hello, I encountered this behavior that I don’t understand. I am defining a wrapper around an array and using the AbstractArray interface: abstract type aw{T,N} \<: AbstractArray{T,N} end struct wrap2{T,N} \<: aw{T,N} …

---

## [Implement an efficient dot-product-like algorithm for two or more vectors?](https://discourse.julialang.org/t/implement-an-efficient-dot-product-like-algorithm-for-two-or-more-vectors/19623)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 4\
**Last updated:** [January 14, 2019, 5:02pm UTC](https://discourse.julialang.org/t/implement-an-efficient-dot-product-like-algorithm-for-two-or-more-vectors/19623 "2019-01-14T17:02:06Z")

</div>

I’m trying to fill a vector A of length n with the dot-product of two vectors x and y like this A = fill(sum(x\[i\]\*y\[i\] for i in eachindex(x)), n) For three vectors x, y, and z, this can be written as B = fill(sum(x\[i\]…

---

## [ODBC example for prepared statement doesn't work](https://discourse.julialang.org/t/odbc-example-for-prepared-statement-doesnt-work/15215)

<div class="topic-metadata">

**Author:** [@jonjilla](https://discourse.julialang.org/u/jonjilla)\
**Replies:** 7\
**Last updated:** [January 14, 2019, 4:24pm UTC](https://discourse.julialang.org/t/odbc-example-for-prepared-statement-doesnt-work/15215 "2019-01-14T16:24:08Z")

</div>

Hello, this example in the ODBC documentation for how to execute a prepared statement doesn’t seem to work # prepare a statement with 3 parameters marked by the '?' character stmt = ODBC.prepare(dsn, "INSERT INTO cool\_…

---

## [CartesianIndices and oneunit()](https://discourse.julialang.org/t/cartesianindices-and-oneunit/19590)

<div class="topic-metadata">

**Author:** [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Replies:** 8\
**Last updated:** [January 14, 2019, 2:50pm UTC](https://discourse.julialang.org/t/cartesianindices-and-oneunit/19590 "2019-01-14T14:50:09Z")

</div>

I’m trying to run the following code from Tim Holy’s blog post to learn about Cartesian indices: function boxcar3(A::AbstractArray) out = similar(A) R = CartesianIndices(A) Ifirst, Ilast = first(R), last(R) …

---

## [AttoBot for Pkg3 projects](https://discourse.julialang.org/t/attobot-for-pkg3-projects/13371)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 11\
**Last updated:** [January 14, 2019, 12:46pm UTC](https://discourse.julialang.org/t/attobot-for-pkg3-projects/13371 "2019-01-14T12:46:45Z")

</div>

Currently, new packages that only supports v0.7+ will not need the REQUIRE file, however attobot will require a REQUIRE file, how should I register (and maybe update) the package then? Or should I add a REQUIRE according…

---

## [CartesianIndex tuple accessor](https://discourse.julialang.org/t/cartesianindex-tuple-accessor/19613)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [January 14, 2019, 11:52am UTC](https://discourse.julialang.org/t/cartesianindex-tuple-accessor/19613 "2019-01-14T11:52:42Z")

</div>

What is the API for extracting the I from a CartesianIndex(I)? I need it as a Tuple of integers. I can convert, eg convert(Tuple, CartesianIndex((1, 2, 3))) but I am wondering if this is the supported way.

---

## [Nearest Correlation Matrix](https://discourse.julialang.org/t/nearest-correlation-matrix/14713)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 1\
**Last updated:** [January 14, 2019, 11:43am UTC](https://discourse.julialang.org/t/nearest-correlation-matrix/14713 "2019-01-14T11:43:27Z")

</div>

Does anyone know if there’s a native Julia implementation of finding the Nearest Correlation Matrix?

---

## [How does the julia 1.0 Pkg handle diamond dependencies?](https://discourse.julialang.org/t/how-does-the-julia-1-0-pkg-handle-diamond-dependencies/19558)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 9\
**Last updated:** [January 14, 2019, 12:26am UTC](https://discourse.julialang.org/t/how-does-the-julia-1-0-pkg-handle-diamond-dependencies/19558 "2019-01-14T00:26:40Z")

</div>

just informed myself about diamond dependency problems, i.e. the problem when a package A depends on package B and C which both depend on another package D, however with different versions. I.e. package B uses D v1.2 and…

---

## [Improving performance elegantly - type stability](https://discourse.julialang.org/t/improving-performance-elegantly-type-stability/19568)

<div class="topic-metadata">

**Author:** [@OlivierHnt](https://discourse.julialang.org/u/OlivierHnt)\
**Replies:** 20\
**Last updated:** [January 13, 2019, 1:18pm UTC](https://discourse.julialang.org/t/improving-performance-elegantly-type-stability/19568 "2019-01-13T13:18:05Z")

</div>

Good afternoon, I have a couple of questions on how to improve performance. I read (a couple of times) the Performance Tips in the documentation but not everything is clear. In fact, I became a little paranoid about “T…

---

## [Plotting error ("hold all-plots")](https://discourse.julialang.org/t/plotting-error-hold-all-plots/19580)

<div class="topic-metadata">

**Author:** [@Aquaman](https://discourse.julialang.org/u/Aquaman)\
**Replies:** 9\
**Last updated:** [January 13, 2019, 11:38am UTC](https://discourse.julialang.org/t/plotting-error-hold-all-plots/19580 "2019-01-13T11:38:30Z")

</div>

Dear All, now I am plotting some figures (simple) usig Julia, but It seems not working, i think “hold on” could be the reason?? function Bernstein(n,i,t) Brnbasis=factorial(BigInt(n))/factorial(BigInt(i))/factorial(Bi…

---

## [Explain perm in permutedims](https://discourse.julialang.org/t/explain-perm-in-permutedims/19582)

<div class="topic-metadata">

**Author:** [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Replies:** 2\
**Last updated:** [January 13, 2019, 8:14am UTC](https://discourse.julialang.org/t/explain-perm-in-permutedims/19582 "2019-01-13T08:14:23Z")

</div>

I’m trying to understand exactly what perm is in the permutedims function. The docs say: “perm is a vector specifying a permutation of length ndims(A)”, but I don’t understand what this means. To transpose a 2D array,…

---

## [@sprintf not defined](https://discourse.julialang.org/t/sprintf-not-defined/19188)

<div class="topic-metadata">

**Author:** [@Aquaman](https://discourse.julialang.org/u/Aquaman)\
**Replies:** 2\
**Last updated:** [January 13, 2019, 7:23am UTC](https://discourse.julialang.org/t/sprintf-not-defined/19188 "2019-01-13T07:23:57Z")

</div>

Dear All, I am a new julia user, I would like to ask, how can I remove the following bug in julia: ERROR: LoadError: LoadError: UndefVarError: @sprintf not defined Kind regards, Yaakov

---

## [Performance of matrix division](https://discourse.julialang.org/t/performance-of-matrix-division/19477)

<div class="topic-metadata">

**Author:** [@judober](https://discourse.julialang.org/u/judober)\
**Replies:** 8\
**Last updated:** [January 12, 2019, 10:15pm UTC](https://discourse.julialang.org/t/performance-of-matrix-division/19477 "2019-01-12T22:15:26Z")

</div>

I have a question regarding the performance of matrix division (/). During some calculations, I noticed a huge impact of 3x3-Matrix divisions compared to expectations I had from a similar matlab program. Therefore, I ma…

---

## [Elementwise operators](https://discourse.julialang.org/t/elementwise-operators/19529)

<div class="topic-metadata">

**Author:** [@rcnlee](https://discourse.julialang.org/u/rcnlee)\
**Replies:** 3\
**Last updated:** [January 12, 2019, 7:23pm UTC](https://discourse.julialang.org/t/elementwise-operators/19529 "2019-01-12T19:23:22Z")

</div>

What’s actually going on under the hood when using elementwise operators? e.g., z=x.\*y. When I look at the syntax tree, the head is call and arg\[1\] is :(.\*). However, I’m not sure where that symbol is actually defined.…

---

## [Convention/package for chunking array stream?](https://discourse.julialang.org/t/convention-package-for-chunking-array-stream/19395)

<div class="topic-metadata">

**Author:** [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Replies:** 4\
**Last updated:** [January 12, 2019, 4:55pm UTC](https://discourse.julialang.org/t/convention-package-for-chunking-array-stream/19395 "2019-01-12T16:55:27Z")

</div>

Is there a convention or package for reading/writing in an array by chunks? I understand I could do it myself piecewise using read, but it seems that this could quickly become complicated when taking into account multipl…

---

## [Vcat taking up all the memory](https://discourse.julialang.org/t/vcat-taking-up-all-the-memory/19460)

<div class="topic-metadata">

**Author:** [@rakeshvar](https://discourse.julialang.org/u/rakeshvar)\
**Replies:** 2\
**Last updated:** [January 12, 2019, 12:54am UTC](https://discourse.julialang.org/t/vcat-taking-up-all-the-memory/19460 "2019-01-12T00:54:58Z")

</div>

VERSION = v"0.6.2" I have a triangle/jagged array of a data structure that contains a vector d and a coefficient. I want to find the elementwise minimum and maximum of all the ds of the datastructures in the jagged arra…

---

## [Interface for \`Number\`](https://discourse.julialang.org/t/interface-for-number/2723)

<div class="topic-metadata">

**Author:** [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Replies:** 16\
**Last updated:** [January 11, 2019, 11:49pm UTC](https://discourse.julialang.org/t/interface-for-number/2723 "2019-01-11T23:49:26Z")

</div>

I recently ran into an issue overriding zero for my own Number: julia\> immutable Infinity \<: Number end julia\> Base.zero(::Infinity) = 0 julia\> import Base: + julia\> +(::Infinity,::Int) = Infinity() + (generic functi…

---

## [Makie visualize heat distribution on surface](https://discourse.julialang.org/t/makie-visualize-heat-distribution-on-surface/19541)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 0\
**Last updated:** [January 11, 2019, 9:14pm UTC](https://discourse.julialang.org/t/makie-visualize-heat-distribution-on-surface/19541 "2019-01-11T21:14:55Z")

</div>

I would like to plot a heat distribution on a 2d sphere, something like this. Here is what I tried: using Makie n = 50 m = 2n θ = range(0,stop=π, length=n) φ = range(0, stop=2π, length=m) x = \[sin(θ)\*cos(φ) for θ in θ…

---

## [How to interpret lowered code?](https://discourse.julialang.org/t/how-to-interpret-lowered-code/19538)

<div class="topic-metadata">

**Author:** [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Replies:** 2\
**Last updated:** [January 11, 2019, 8:59pm UTC](https://discourse.julialang.org/t/how-to-interpret-lowered-code/19538 "2019-01-11T20:59:38Z")

</div>

When trying to understand what happens under Julia’s hood, lowered code is a first step (the “entrance to the rabbit hole”, as @mbauman put it) . But while CodeInfo objects print relatively nicely in the REPL, there see…

---

## [Can a compatibility entry for Pkg specify a commit SHA in Project.toml?](https://discourse.julialang.org/t/can-a-compatibility-entry-for-pkg-specify-a-commit-sha-in-project-toml/19539)

<div class="topic-metadata">

**Author:** [@Marco\_Cusumano-Towne](https://discourse.julialang.org/u/Marco_Cusumano-Towne)\
**Replies:** 1\
**Last updated:** [January 11, 2019, 8:54pm UTC](https://discourse.julialang.org/t/can-a-compatibility-entry-for-pkg-specify-a-commit-sha-in-project-toml/19539 "2019-01-11T20:54:23Z")

</div>

Can the \[compat\] section of a Project.toml file indicate compatibility with a specific commit? This does not seem to be mentioned in the documentation.

---

## [Why does (AbstractArray{Union{Number, T}} where T \<: Nothing) != (AbstractArray{Union{Number, Nothing}})](https://discourse.julialang.org/t/why-does-abstractarray-union-number-t-where-t-nothing-abstractarray-union-number-nothing/19531)

<div class="topic-metadata">

**Author:** [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Replies:** 1\
**Last updated:** [January 11, 2019, 7:33pm UTC](https://discourse.julialang.org/t/why-does-abstractarray-union-number-t-where-t-nothing-abstractarray-union-number-nothing/19531 "2019-01-11T19:33:50Z")

</div>

In the search to find something that would match an Vector{Union{MyType,Nothing}} and Vector{MyType} but not Vector{Nothing}. I found the signature that works is Vector{Union{MyType,T}} where T\<:Nothing, but now I need …

---

## [Registering a new package in General](https://discourse.julialang.org/t/registering-a-new-package-in-general/13900)

<div class="topic-metadata">

**Author:** [@zsunberg](https://discourse.julialang.org/u/zsunberg)\
**Replies:** 7\
**Last updated:** [January 11, 2019, 3:09pm UTC](https://discourse.julialang.org/t/registering-a-new-package-in-general/13900 "2019-01-11T15:09:50Z")

</div>

Hi all, I appologize if this info is already available somewhere else - just send me a link if I have missed it. I am trying to understand what the norms are about registering new packages in the General registry. Firs…

---

## [How to dispatch on an array of T or Union{Nothing,T} but not nothing](https://discourse.julialang.org/t/how-to-dispatch-on-an-array-of-t-or-union-nothing-t-but-not-nothing/19504)

<div class="topic-metadata">

**Author:** [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Replies:** 3\
**Last updated:** [January 11, 2019, 1:26pm UTC](https://discourse.julialang.org/t/how-to-dispatch-on-an-array-of-t-or-union-nothing-t-but-not-nothing/19504 "2019-01-11T13:26:14Z")

</div>

I am looking for a concise way to match an AbstractArray of T or Union{Nothing,T} but not Nothing. Does anyone have any ideas how to do that? The general test I have been using is the following, with the ideal result be…

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

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