# General Usage

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

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

**Page:** 695

---

## [Suggestions needed: speed up optimization](https://discourse.julialang.org/t/suggestions-needed-speed-up-optimization/47449)

<div class="topic-metadata">

**Author:** [@DShiu](https://discourse.julialang.org/u/DShiu)\
**Replies:** 31\
**Last updated:** [October 4, 2020, 7:06pm UTC](https://discourse.julialang.org/t/suggestions-needed-speed-up-optimization/47449 "2020-10-04T19:06:19Z")

</div>

I need to maximize a likelihood function which has 18 parameters using a large sample with 1 million observations. The objective function is defined as function loglike(θ, x, y, R, c, d, p0, B) prob = \[choice\_prob\_n…

---

## [Multiply dense arrays](https://discourse.julialang.org/t/multiply-dense-arrays/47724)

<div class="topic-metadata">

**Author:** [@jleman](https://discourse.julialang.org/u/jleman)\
**Replies:** 14\
**Last updated:** [October 4, 2020, 6:38pm UTC](https://discourse.julialang.org/t/multiply-dense-arrays/47724 "2020-10-04T18:38:11Z")

</div>

Is there a way to speed up basic multiplication of dense arrays? I have the following: using BenchmarkTools multiplyAndSum(Gmρ,Gρq) = sum(Gmρ .\* Gρq) dim = 500 #target is 3000 Gmρ = \[rand(dim,18) for \_ in 1:1024\] Gρq…

---

## [Promote\_type in @generated](https://discourse.julialang.org/t/promote-type-in-generated/47729)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 8\
**Last updated:** [October 4, 2020, 5:16pm UTC](https://discourse.julialang.org/t/promote-type-in-generated/47729 "2020-10-04T17:16:44Z")

</div>

Hi, I want to write toggle, a typestable version of the q ? a : b syntax. What I am writing now has the disadvantage of evaluating both a and b for all values of q. A macro might save the day, but this is not the poin…

---

## [How to deal with these Float32\[1.4765211f6\]?](https://discourse.julialang.org/t/how-to-deal-with-these-float32-1-4765211f6/47741)

<div class="topic-metadata">

**Author:** [@ZhouZhuofei](https://discourse.julialang.org/u/ZhouZhuofei)\
**Replies:** 2\
**Last updated:** [October 4, 2020, 4:23pm UTC](https://discourse.julialang.org/t/how-to-deal-with-these-float32-1-4765211f6/47741 "2020-10-04T16:23:07Z")

</div>

my code here: julia\> data\_y 255-element Array{Any,1}: Float32\[4805.912\] Float32\[10600.066\] Float32\[16394.223\] Float32\[22188.377\] Float32\[27982.531\] Float32\[33776.684\] Float32\[39570.844\] Float32\[45364.992\] Float…

---

## [Failure with \`lshr\_int\` (intrinsic for \>\>) on UInt256 type](https://discourse.julialang.org/t/failure-with-lshr-int-intrinsic-for-on-uint256-type/47738)

<div class="topic-metadata">

**Author:** [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Replies:** 5\
**Last updated:** [October 4, 2020, 4:17pm UTC](https://discourse.julialang.org/t/failure-with-lshr-int-intrinsic-for-on-uint256-type/47738 "2020-10-04T16:17:51Z")

</div>

Basically lshr\_int works as expected when called directly, but not when wrapped in a function. I need to understand better the failure to find a proper fix in BitIntegers. Here is a demo: julia\> using BitIntegers; x = r…

---

## [Operations on elements of a common index of an array of matrices](https://discourse.julialang.org/t/operations-on-elements-of-a-common-index-of-an-array-of-matrices/47715)

<div class="topic-metadata">

**Author:** [@jleman](https://discourse.julialang.org/u/jleman)\
**Replies:** 7\
**Last updated:** [October 4, 2020, 3:05pm UTC](https://discourse.julialang.org/t/operations-on-elements-of-a-common-index-of-an-array-of-matrices/47715 "2020-10-04T15:05:06Z")

</div>

I have an array of matrices. Is it possible to update groups of common indices in place? The code below doesn’t work but I think conveys what I am trying to do. Yes it would be easier to do this with a 3D matrix, but …

---

## [Objects whose structure can be redefined](https://discourse.julialang.org/t/objects-whose-structure-can-be-redefined/47733)

<div class="topic-metadata">

**Author:** [@fusion809](https://discourse.julialang.org/u/fusion809)\
**Replies:** 8\
**Last updated:** [October 4, 2020, 11:30am UTC](https://discourse.julialang.org/t/objects-whose-structure-can-be-redefined/47733 "2020-10-04T11:30:17Z")

</div>

One thing I’ve noticed about Julia that is a little frustrating is that if I define an object like this: struct paramObj g::Float64 l::Float64 end params = paramObj(9.81, 1.0); and then import a file that contai…

---

## [Comparing functions with their alias in GLM.jl](https://discourse.julialang.org/t/comparing-functions-with-their-alias-in-glm-jl/47593)

<div class="topic-metadata">

**Author:** [@yordiak](https://discourse.julialang.org/u/yordiak)\
**Replies:** 13\
**Last updated:** [October 4, 2020, 8:34am UTC](https://discourse.julialang.org/t/comparing-functions-with-their-alias-in-glm-jl/47593 "2020-10-04T08:34:59Z")

</div>

Not sure how clear the title is or whether this is the right place for asking the following question, but any way… :slight\_smile: I am testing the GLM package mostly for educational purposes. In the package documentati…

---

## [Strange errors occurred when I optimized with Zygote and Optim](https://discourse.julialang.org/t/strange-errors-occurred-when-i-optimized-with-zygote-and-optim/47461)

<div class="topic-metadata">

**Author:** [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Replies:** 3\
**Last updated:** [October 4, 2020, 7:09am UTC](https://discourse.julialang.org/t/strange-errors-occurred-when-i-optimized-with-zygote-and-optim/47461 "2020-10-04T07:09:01Z")

</div>

Why do I get a bivariate gradient function when I optimize the objective function?How can I solve it? using Zygote using Optim using RecursiveArrayTools #This is the target function that I’m optimizing function ge…

---

## [Flux model on CPU runs slowly](https://discourse.julialang.org/t/flux-model-on-cpu-runs-slowly/47723)

<div class="topic-metadata">

**Author:** [@AquaIndigo](https://discourse.julialang.org/u/AquaIndigo)\
**Replies:** 3\
**Last updated:** [October 4, 2020, 2:54am UTC](https://discourse.julialang.org/t/flux-model-on-cpu-runs-slowly/47723 "2020-10-04T02:54:10Z")

</div>

I find the Flux model on CPU runs more slowly than that on GPU: julia\> m = Chain( Dense(2250, 500, σ), Dense(500, 50, tanh), Dense(50, 7, σ)); julia\> X = Float32.(X); julia\> size(X) (…

---

## [Changing the values of axes without resizing the image/figure in Plots.jl](https://discourse.julialang.org/t/changing-the-values-of-axes-without-resizing-the-image-figure-in-plots-jl/47702)

<div class="topic-metadata">

**Author:** [@libensvivit](https://discourse.julialang.org/u/libensvivit)\
**Replies:** 4\
**Last updated:** [October 3, 2020, 9:53pm UTC](https://discourse.julialang.org/t/changing-the-values-of-axes-without-resizing-the-image-figure-in-plots-jl/47702 "2020-10-03T21:53:20Z")

</div>

Hey, I have an image of 300x300 pixels loaded in Plots and I’m having a hard time modifying the axes without altering the image. If I change the xlims, the image gets resized. If I try xticks, it gets weird if I pass 30…

---

## [Executing array of functions much slower than executing functions in series](https://discourse.julialang.org/t/executing-array-of-functions-much-slower-than-executing-functions-in-series/47674)

<div class="topic-metadata">

**Author:** [@Yamen](https://discourse.julialang.org/u/Yamen)\
**Replies:** 10\
**Last updated:** [October 3, 2020, 8:32pm UTC](https://discourse.julialang.org/t/executing-array-of-functions-much-slower-than-executing-functions-in-series/47674 "2020-10-03T20:32:14Z")

</div>

I have a very performance sensitive application that needs to activate a neural network on a per row basis for a large number of rows. Consider a network with 4 input values and 1 output value, with a few layers in betw…

---

## [How to get the variable numbers for a julia function](https://discourse.julialang.org/t/how-to-get-the-variable-numbers-for-a-julia-function/36682)

<div class="topic-metadata">

**Author:** [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Replies:** 21\
**Last updated:** [October 3, 2020, 6:36pm UTC](https://discourse.julialang.org/t/how-to-get-the-variable-numbers-for-a-julia-function/36682 "2020-10-03T18:36:53Z")

</div>

I have a function called f for example. function f(x1,x2,x3) x1+x2\*x3 end How can get the number of variable of this function? For this example it should return 3.

---

## [Instability with DifferentialEquations.jl](https://discourse.julialang.org/t/instability-with-differentialequations-jl/7874)

<div class="topic-metadata">

**Author:** [@newbie](https://discourse.julialang.org/u/newbie)\
**Replies:** 4\
**Last updated:** [October 3, 2020, 6:25pm UTC](https://discourse.julialang.org/t/instability-with-differentialequations-jl/7874 "2020-10-03T18:25:04Z")

</div>

I am trying to solve a second order ODE equation by using SecondOrderODEProblem as problem type. Consistently, I have encountered WARNING: Instability detected. Aborting. I have tried various solver and still, the probl…

---

## [Plots.jl how to create a heat map from several curves](https://discourse.julialang.org/t/plots-jl-how-to-create-a-heat-map-from-several-curves/47683)

<div class="topic-metadata">

**Author:** [@a\_garval](https://discourse.julialang.org/u/a_garval)\
**Replies:** 6\
**Last updated:** [October 3, 2020, 4:56pm UTC](https://discourse.julialang.org/t/plots-jl-how-to-create-a-heat-map-from-several-curves/47683 "2020-10-03T16:56:33Z")

</div>

So I have about 100 different curves and I’d like to create a heatmap from them. These curves each represent possible solutions to a differential equation and I’d like to create a sort of density plot from them so that i…

---

## [Calling for people using multithreading heavily, memory fragmentation problem](https://discourse.julialang.org/t/calling-for-people-using-multithreading-heavily-memory-fragmentation-problem/47687)

<div class="topic-metadata">

**Author:** [@Patrick\_Chow](https://discourse.julialang.org/u/Patrick_Chow)\
**Replies:** 1\
**Last updated:** [October 3, 2020, 12:35pm UTC](https://discourse.julialang.org/t/calling-for-people-using-multithreading-heavily-memory-fragmentation-problem/47687 "2020-10-03T12:35:37Z")

</div>

Hi Guys, I use Julia for computation intensive tasks. And of coz the best way is to reduce my run time is to use multithreading and parallelize all my work. Sometimes, my works will require larger per thread memory and…

---

## [Macro to create a function with a variable number of elseif branches](https://discourse.julialang.org/t/macro-to-create-a-function-with-a-variable-number-of-elseif-branches/47665)

<div class="topic-metadata">

**Author:** [@disberd](https://discourse.julialang.org/u/disberd)\
**Replies:** 10\
**Last updated:** [October 3, 2020, 12:31pm UTC](https://discourse.julialang.org/t/macro-to-create-a-function-with-a-variable-number-of-elseif-branches/47665 "2020-10-03T12:31:57Z")

</div>

Hello, I am starting to try and use/understand meta-programming and wanted to create a macro to overload the getproperty function for custom types that are custom implementation of the Point in GeometryBasics (subtypes …

---

## [I can solve the equations by ode45 in MATLAB, However, failed in julia with Warning: Instability detected. Aborting](https://discourse.julialang.org/t/i-can-solve-the-equations-by-ode45-in-matlab-however-failed-in-julia-with-warning-instability-detected-aborting/47678)

<div class="topic-metadata">

**Author:** [@Rozarspady](https://discourse.julialang.org/u/Rozarspady)\
**Replies:** 1\
**Last updated:** [October 3, 2020, 12:10pm UTC](https://discourse.julialang.org/t/i-can-solve-the-equations-by-ode45-in-matlab-however-failed-in-julia-with-warning-instability-detected-aborting/47678 "2020-10-03T12:10:34Z")

</div>

i have use the same odefun in both matlab and julia,however, i got a warning in julia,the codes are as follows. I have changed the methods in julia and dimin,maxiters, but failed. using DifferentialEquations u0=\[2.46…

---

## [DIffEqFlux loss function with variable solve options](https://discourse.julialang.org/t/diffeqflux-loss-function-with-variable-solve-options/47361)

<div class="topic-metadata">

**Author:** [@FHell](https://discourse.julialang.org/u/FHell)\
**Replies:** 6\
**Last updated:** [October 3, 2020, 6:42am UTC](https://discourse.julialang.org/t/diffeqflux-loss-function-with-variable-solve-options/47361 "2020-10-03T06:42:02Z")

</div>

Does someone know a good way to pass solve options to a custom loss function? We are building a package and would like to provide a loss function of the DiffEqFlux type, and I would like the user to be able to control th…

---

## [Weird error with optional arguments](https://discourse.julialang.org/t/weird-error-with-optional-arguments/47684)

<div class="topic-metadata">

**Author:** [@subramanya\_gautam](https://discourse.julialang.org/u/subramanya_gautam)\
**Replies:** 5\
**Last updated:** [October 3, 2020, 6:58am UTC](https://discourse.julialang.org/t/weird-error-with-optional-arguments/47684 "2020-10-03T06:58:30Z")

</div>

I am pretty new to julia - and I encountered this error when I was trying to implement a code that takes an optional argument that is a dict. So I try function test\_optional(x,y,z=nothing) print("$x,$y") if z!=n…

---

## [Accuracy\_score](https://discourse.julialang.org/t/accuracy-score/47650)

<div class="topic-metadata">

**Author:** [@Mun\_Barimukh](https://discourse.julialang.org/u/Mun_Barimukh)\
**Replies:** 2\
**Last updated:** [October 3, 2020, 4:27am UTC](https://discourse.julialang.org/t/accuracy-score/47650 "2020-10-03T04:27:12Z")

</div>

How to check the accuracy for linear regression model.

---

## [DataFrames.leftjoin now working? leftjoin not defined](https://discourse.julialang.org/t/dataframes-leftjoin-now-working-leftjoin-not-defined/47667)

<div class="topic-metadata">

**Author:** [@psabela](https://discourse.julialang.org/u/psabela)\
**Replies:** 2\
**Last updated:** [October 3, 2020, 4:06am UTC](https://discourse.julialang.org/t/dataframes-leftjoin-now-working-leftjoin-not-defined/47667 "2020-10-03T04:06:18Z")

</div>

julia\> using DataFrames julia\> jobs = DataFrame(ID = \[20, 60\], Job = \[“Lawyer”, “Astronaut”\]) 2×2 DataFrame │ Row │ ID │ Job │ │ │ Int64 │ String │ ├─────┼───────┼───────────┤ │ 1 │ 20 │ Lawyer…

---

## [Iteration using array of arrays/matrices vs iteration over matrix subsets](https://discourse.julialang.org/t/iteration-using-array-of-arrays-matrices-vs-iteration-over-matrix-subsets/47661)

<div class="topic-metadata">

**Author:** [@jleman](https://discourse.julialang.org/u/jleman)\
**Replies:** 2\
**Last updated:** [October 3, 2020, 12:00am UTC](https://discourse.julialang.org/t/iteration-using-array-of-arrays-matrices-vs-iteration-over-matrix-subsets/47661 "2020-10-03T00:00:15Z")

</div>

It seems to me that in past versions of Julia the array of arrays or array of matrices approach for iteration usually outperformed iterating over matrix subsets. That gap seems to be smaller in the more recent version. …

---

## [Trying to launch Julia cluster under PBS](https://discourse.julialang.org/t/trying-to-launch-julia-cluster-under-pbs/47558)

<div class="topic-metadata">

**Author:** [@Jeff\_Becker](https://discourse.julialang.org/u/Jeff_Becker)\
**Replies:** 8\
**Last updated:** [October 2, 2020, 9:28pm UTC](https://discourse.julialang.org/t/trying-to-launch-julia-cluster-under-pbs/47558 "2020-10-02T21:28:04Z")

</div>

Hi. I used PBS qsub to get four nodes on our cluster. I put the contents of $PBS\_NODEFILE in the array hosts below. After doing “using Distributed”, I tried using addprocs as below, and I don’t understand what to do abou…

---

## [Are Python packages called in julia faster than in python](https://discourse.julialang.org/t/are-python-packages-called-in-julia-faster-than-in-python/47644)

<div class="topic-metadata">

**Author:** [@MalteMederacke](https://discourse.julialang.org/u/MalteMederacke)\
**Replies:** 12\
**Last updated:** [October 2, 2020, 5:04pm UTC](https://discourse.julialang.org/t/are-python-packages-called-in-julia-faster-than-in-python/47644 "2020-10-02T17:04:10Z")

</div>

Hi guys, basicly this. I am not a computer scientist, but I am curious, if I call a python package with julia, does it run faster than in python? Or is it the same or even slower.

---

## [How to time julia's choleskey factorization?](https://discourse.julialang.org/t/how-to-time-julias-choleskey-factorization/47627)

<div class="topic-metadata">

**Author:** [@vkv](https://discourse.julialang.org/u/vkv)\
**Replies:** 8\
**Last updated:** [October 2, 2020, 2:44pm UTC](https://discourse.julialang.org/t/how-to-time-julias-choleskey-factorization/47627 "2020-10-02T14:44:03Z")

</div>

Hi, I’m trying to compare timings of julia’s cholesky factorization and LAPACK.potrf! function. The timings of julia’s cholesky function is varying from 50 \\mu s to 100 \\mu s and LAPACK.potrf! is blazingly fast varying…

---

## [The JuliaDebug repo: how to be helpful to newbies (and old hands as well)?](https://discourse.julialang.org/t/the-juliadebug-repo-how-to-be-helpful-to-newbies-and-old-hands-as-well/47618)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 12\
**Last updated:** [October 2, 2020, 2:39pm UTC](https://discourse.julialang.org/t/the-juliadebug-repo-how-to-be-helpful-to-newbies-and-old-hands-as-well/47618 "2020-10-02T14:39:01Z")

</div>

When one visits JuliaDebug, the page shows about a dozen repos but no guidance as to what does what, what is live, and how to make sense of it all. I don’t have a good answer yet, but how about you all?

---

## [Is there some minimal list of packages (almost) all users should use?](https://discourse.julialang.org/t/is-there-some-minimal-list-of-packages-almost-all-users-should-use/47583)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 7\
**Last updated:** [October 2, 2020, 12:19pm UTC](https://discourse.julialang.org/t/is-there-some-minimal-list-of-packages-almost-all-users-should-use/47583 "2020-10-02T12:19:29Z")

</div>

I do see e.g. brand new ConcreateStructs.jl but it may be too new, so I have established packages in mind at least. I’m not thinking of e.g. some statistics package, but to add language features (and well Revise.jl), no…

---

## [Pkg\> dev --local /some/path doesn't make a local clone in ./dev](https://discourse.julialang.org/t/pkg-dev-local-some-path-doesnt-make-a-local-clone-in-dev/47316)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 5\
**Last updated:** [October 2, 2020, 9:08am UTC](https://discourse.julialang.org/t/pkg-dev-local-some-path-doesnt-make-a-local-clone-in-dev/47316 "2020-10-02T09:08:05Z")

</div>

I am trying to use pkg\> dev --local for a package available locally, but it seems that --local is ignored and no copy in dev is made. Is this expected behavior or a known issue? dev --local works for registered packages…

---

## [Has any attempt been made to transpile Julia to JS?](https://discourse.julialang.org/t/has-any-attempt-been-made-to-transpile-julia-to-js/47386)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 12\
**Last updated:** [October 2, 2020, 4:25am UTC](https://discourse.julialang.org/t/has-any-attempt-been-made-to-transpile-julia-to-js/47386 "2020-10-02T04:25:51Z")

</div>

Are there plans to do so? I think it may open up new horizons: web UIs, …

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

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