# General Usage

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

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

**Page:** 876

---

## [Performance of log.(x)](https://discourse.julialang.org/t/performance-of-log-x/23039)

<div class="topic-metadata">

**Author:** [@pmags](https://discourse.julialang.org/u/pmags)\
**Replies:** 11\
**Last updated:** [April 12, 2019, 6:00pm UTC](https://discourse.julialang.org/t/performance-of-log-x/23039 "2019-04-12T18:00:50Z")

</div>

I’m a newcomer to Julia from Python and was surprised to find vectorized log so slow in Julia. Am I doing something wrong in the code below? As noted here numpy.log seems to be about 6x faster than Base.log broadcast to…

---

## [Close function Julia](https://discourse.julialang.org/t/close-function-julia/23081)

<div class="topic-metadata">

**Author:** [@Aquaman](https://discourse.julialang.org/u/Aquaman)\
**Replies:** 3\
**Last updated:** [April 12, 2019, 3:11pm UTC](https://discourse.julialang.org/t/close-function-julia/23081 "2019-04-12T15:11:23Z")

</div>

Hi everyone, which command in Julia is equal to close in Matlab? e.g. if i==1 close end

---

## [Extra several columns from a dataframe to create a new dataframe in julia](https://discourse.julialang.org/t/extra-several-columns-from-a-dataframe-to-create-a-new-dataframe-in-julia/23049)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 5\
**Last updated:** [April 12, 2019, 2:55pm UTC](https://discourse.julialang.org/t/extra-several-columns-from-a-dataframe-to-create-a-new-dataframe-in-julia/23049 "2019-04-12T14:55:27Z")

</div>

This is a simple task. Suppose I have a dataframe with name x. And I’d like to extract the columns with name x.name1, x.name3, x.name4, and combine them to create a new data frame using Julia. I tried the following and …

---

## [Strange Powershell related error](https://discourse.julialang.org/t/strange-powershell-related-error/23029)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 14\
**Last updated:** [April 12, 2019, 1:15pm UTC](https://discourse.julialang.org/t/strange-powershell-related-error/23029 "2019-04-12T13:15:37Z")

</div>

I am getting the following error when I start Atom with Juno installed: We tried to start Julia with the \`powershell\` wrapper but could not find \`powershell\` or \`where\` on your \`PATH\` . Please make sure \`%SYSTE…

---

## [Syntax: unexpected "end"](https://discourse.julialang.org/t/syntax-unexpected-end/23075)

<div class="topic-metadata">

**Author:** [@yingjie\_zhu](https://discourse.julialang.org/u/yingjie_zhu)\
**Replies:** 1\
**Last updated:** [April 12, 2019, 12:35pm UTC](https://discourse.julialang.org/t/syntax-unexpected-end/23075 "2019-04-12T12:35:50Z")

</div>

这个问题怎么解决？？

---

## [Tricky parametric type dispatch](https://discourse.julialang.org/t/tricky-parametric-type-dispatch/23064)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 4\
**Last updated:** [April 12, 2019, 12:02pm UTC](https://discourse.julialang.org/t/tricky-parametric-type-dispatch/23064 "2019-04-12T12:02:04Z")

</div>

I would like to dispatch a method like this, where T gets the type \<: AbstractParticles and the type parameters end up in F and NT. function Base.union(p1::T{F,NT},p2::S{F,NS}) where T \<: AbstractParticles where S \<: Ab…

---

## [Adding an unregistred package](https://discourse.julialang.org/t/adding-an-unregistred-package/22988)

<div class="topic-metadata">

**Author:** [@marouane](https://discourse.julialang.org/u/marouane)\
**Replies:** 4\
**Last updated:** [April 12, 2019, 9:47am UTC](https://discourse.julialang.org/t/adding-an-unregistred-package/22988 "2019-04-12T09:47:12Z")

</div>

Hello Guys, i wanna know how to add an unregistred package, because i need it in my code i tried and the kernel asked me to enter the username and the password of mu github account, i did that but it didn’t work.

---

## [Randomly generate a sequence of numbers one by one using the rand function in Distributions module](https://discourse.julialang.org/t/randomly-generate-a-sequence-of-numbers-one-by-one-using-the-rand-function-in-distributions-module/23022)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 17\
**Last updated:** [April 12, 2019, 6:24am UTC](https://discourse.julialang.org/t/randomly-generate-a-sequence-of-numbers-one-by-one-using-the-rand-function-in-distributions-module/23022 "2019-04-12T06:24:18Z")

</div>

Hi, the random function in the Distributions module is very useful for generating a sequence / vector / list of random numbers one by one based on a given random number generator and a statistical distribution. What I ne…

---

## [Define a static type variable is too Verbose](https://discourse.julialang.org/t/define-a-static-type-variable-is-too-verbose/22779)

<div class="topic-metadata">

**Author:** [@Eric\_Chen](https://discourse.julialang.org/u/Eric_Chen)\
**Replies:** 16\
**Last updated:** [April 12, 2019, 6:20am UTC](https://discourse.julialang.org/t/define-a-static-type-variable-is-too-verbose/22779 "2019-04-12T06:20:43Z")

</div>

Let’s say I want to define a static-type variable inside a function, the data structure is very complex, it is a Vector, containing a Pair, with String =\> Matrix Once defined, I want the Type to be stable and never cha…

---

## [How to set a function to run less than a maximum amount of iterations n that is given?](https://discourse.julialang.org/t/how-to-set-a-function-to-run-less-than-a-maximum-amount-of-iterations-n-that-is-given/23052)

<div class="topic-metadata">

**Author:** [@Engineer43](https://discourse.julialang.org/u/Engineer43)\
**Replies:** 2\
**Last updated:** [April 12, 2019, 2:02am UTC](https://discourse.julialang.org/t/how-to-set-a-function-to-run-less-than-a-maximum-amount-of-iterations-n-that-is-given/23052 "2019-04-12T02:02:48Z")

</div>

I am trying to optimize the rosenbrock function using the ADAM method, but need to make sure that it only iterates n/2 (where n iterations is given by a test code) times. How can I set up a counter to count every time th…

---

## [Function keyword argument packing and unpacking](https://discourse.julialang.org/t/function-keyword-argument-packing-and-unpacking/23053)

<div class="topic-metadata">

**Author:** [@bomber8013](https://discourse.julialang.org/u/bomber8013)\
**Replies:** 2\
**Last updated:** [April 11, 2019, 9:13pm UTC](https://discourse.julialang.org/t/function-keyword-argument-packing-and-unpacking/23053 "2019-04-11T21:13:53Z")

</div>

Current behavior is this: julia\> f(;kwargs...) = kwargs f (generic function with 1 method) julia\> f(a=1, b=2) pairs(::NamedTuple) with 2 entries: :a =\> 1 :b =\> 2 julia\> f(f(a=1, b=2)...) ERROR: MethodError: no met…

---

## [Help me on strange performance slow down using SMatrix](https://discourse.julialang.org/t/help-me-on-strange-performance-slow-down-using-smatrix/23027)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 2\
**Last updated:** [April 11, 2019, 7:00pm UTC](https://discourse.julialang.org/t/help-me-on-strange-performance-slow-down-using-smatrix/23027 "2019-04-11T19:00:29Z")

</div>

function instruct2!(state, U, loc) a, c, b, d = U step = 1 \<\< (loc - 1) step\_2 = 1 \<\< loc for j in 0:step\_2:size(state, 1)-step for i in j+1:j+step u1rows!(state, i, i+step, a, b, c, d)…

---

## [Nan to zero in hot loop?](https://discourse.julialang.org/t/nan-to-zero-in-hot-loop/23018)

<div class="topic-metadata">

**Author:** [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Replies:** 7\
**Last updated:** [April 11, 2019, 3:37pm UTC](https://discourse.julialang.org/t/nan-to-zero-in-hot-loop/23018 "2019-04-11T15:37:07Z")

</div>

I have a function like this : f(x, a) = sum(x. + x .\* log. (a. \*x)) #broadcasted for simplicity Where 0\<=x\[i\] \<=1 and a is positive . When x\[i\] =0,f(x)\[i\] is zero. The logarithm generates problems, because 0\*Inf is N…

---

## [Add image from my files](https://discourse.julialang.org/t/add-image-from-my-files/22977)

<div class="topic-metadata">

**Author:** [@GERSON\_EZEQUIEL\_HERN](https://discourse.julialang.org/u/GERSON_EZEQUIEL_HERN)\
**Replies:** 15\
**Last updated:** [April 11, 2019, 2:50pm UTC](https://discourse.julialang.org/t/add-image-from-my-files/22977 "2019-04-11T14:50:04Z")

</div>

I’m trying to load an image that I have on my computer, but I get this error … someone can audare me … img = load(“C:\\Users\\gerso.julia\\Imagenes\_de\_gerson\\colibri.jpg”); the image, this name is colibri.jpg

---

## [Freeing memory withing struct](https://discourse.julialang.org/t/freeing-memory-withing-struct/23031)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 6\
**Last updated:** [April 11, 2019, 1:35pm UTC](https://discourse.julialang.org/t/freeing-memory-withing-struct/23031 "2019-04-11T13:35:16Z")

</div>

julia\> mutable struct S x::Vector{Matrix{Float64}} S() = new() end julia\> s = S(); julia\> s S(#undef) julia\> s.x ERROR: UndefRefError: access to undefined reference Stacktrace: \[1\] getpro…

---

## [Juno Debugger can't show source code, only lowered code](https://discourse.julialang.org/t/juno-debugger-cant-show-source-code-only-lowered-code/23032)

<div class="topic-metadata">

**Author:** [@plapplop](https://discourse.julialang.org/u/plapplop)\
**Replies:** 4\
**Last updated:** [April 11, 2019, 1:05pm UTC](https://discourse.julialang.org/t/juno-debugger-cant-show-source-code-only-lowered-code/23032 "2019-04-11T13:05:29Z")

</div>

I’m trying to get used to the new Debugger in Juno and I encountered many cases where it is unable to show me the source code, only the lowered code, which is less intuitive (at least for me) to track where I am. I have …

---

## [Unique() to a certain tolerance?](https://discourse.julialang.org/t/unique-to-a-certain-tolerance/23007)

<div class="topic-metadata">

**Author:** [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Replies:** 10\
**Last updated:** [April 11, 2019, 11:07am UTC](https://discourse.julialang.org/t/unique-to-a-certain-tolerance/23007 "2019-04-11T11:07:08Z")

</div>

Hi all, I’m building up a code that evaluates the energy of a lot of spin states, and many of those states have the same energy. Typically about 2^20 different states, but only a few thousand of them have different ener…

---

## [Calling a module from a module in a different directory](https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024)

<div class="topic-metadata">

**Author:** [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Replies:** 7\
**Last updated:** [April 11, 2019, 10:43am UTC](https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024 "2019-04-11T10:43:29Z")

</div>

Hi, just a question about calling a module from another module which is located in a different directory. For instance imagine I have a module mytypes.jl module myTypes export CROCO, krok1 export bite abstract type CRO…

---

## [Lastindex not defined for CartesianIndex](https://discourse.julialang.org/t/lastindex-not-defined-for-cartesianindex/23028)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 0\
**Last updated:** [April 11, 2019, 10:40am UTC](https://discourse.julialang.org/t/lastindex-not-defined-for-cartesianindex/23028 "2019-04-11T10:40:58Z")

</div>

Hi all, I get a method error on the following on v1.1: julia\> i = CartesianIndex{2}(2, 3) CartesianIndex(2, 3) julia\> lastindex(i) ERROR: MethodError: no method matching lastindex(::CartesianIndex{2}) I know that you…

---

## [Multivariate parameter optimization in "3-states differential equations" where two of the states have measured data and one state lacks data.](https://discourse.julialang.org/t/multivariate-parameter-optimization-in-3-states-differential-equations-where-two-of-the-states-have-measured-data-and-one-state-lacks-data/23008)

<div class="topic-metadata">

**Author:** [@pandeysudan27](https://discourse.julialang.org/u/pandeysudan27)\
**Replies:** 1\
**Last updated:** [April 11, 2019, 9:41am UTC](https://discourse.julialang.org/t/multivariate-parameter-optimization-in-3-states-differential-equations-where-two-of-the-states-have-measured-data-and-one-state-lacks-data/23008 "2019-04-11T09:41:25Z")

</div>

I have three differential equations in the form of: $$\\frac{dx}{dt}=ax+y+z$$ $$\\frac{dy}{dt}=x+by+z$$ $$\\frac{dz}{dt}=x+y+cz$$ I have measured data: $$x=\[2+5randn(100)\]$$ $$y=\[0.5+2randn(100)\]$$ I do not have data…

---

## [Keyword function arguments in julia](https://discourse.julialang.org/t/keyword-function-arguments-in-julia/23011)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 3\
**Last updated:** [April 11, 2019, 6:40am UTC](https://discourse.julialang.org/t/keyword-function-arguments-in-julia/23011 "2019-04-11T06:40:23Z")

</div>

function randLocation(area::Area; rng::AbstractRNG = GLOBAL\_RNG) r=rand(rng,2) location = Location() location.x = area.xMin + area.xRange \* r\[1\] location.y = area.yMin + area.yRange \* r\[2\] return …

---

## [NaN gates in julia? (from SIGBOBIK)](https://discourse.julialang.org/t/nan-gates-in-julia-from-sigbobik/23020)

<div class="topic-metadata">

**Author:** [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Replies:** 2\
**Last updated:** [April 11, 2019, 5:12am UTC](https://discourse.julialang.org/t/nan-gates-in-julia-from-sigbobik/23020 "2019-04-11T05:12:05Z")

</div>

Sigbovik produces every year a new edition, where they publish funny academic stuff. One article in the 2019 edition talks about the NaN gates, citing the document: People who work with real numbers are often taught th…

---

## [Filter CartesianIndices](https://discourse.julialang.org/t/filter-cartesianindices/23013)

<div class="topic-metadata">

**Author:** [@yingjerkao](https://discourse.julialang.org/u/yingjerkao)\
**Replies:** 1\
**Last updated:** [April 10, 2019, 9:55pm UTC](https://discourse.julialang.org/t/filter-cartesianindices/23013 "2019-04-10T21:55:57Z")

</div>

I am using CartesianIndex as coordinates for my simulation lattice grid. Since steps are not allow in the constructor of CartesianIndices, is there an efficient way to generate iterators of CartesianIndex’s that pick up…

---

## [Multiplication after transpose much faster than multiplication after PermutedDimsArray](https://discourse.julialang.org/t/multiplication-after-transpose-much-faster-than-multiplication-after-permuteddimsarray/22997)

<div class="topic-metadata">

**Author:** [@tomohiro\_soejima](https://discourse.julialang.org/u/tomohiro_soejima)\
**Replies:** 3\
**Last updated:** [April 10, 2019, 7:45pm UTC](https://discourse.julialang.org/t/multiplication-after-transpose-much-faster-than-multiplication-after-permuteddimsarray/22997 "2019-04-10T19:45:55Z")

</div>

I have been experimenting with matrix multiplication with transpose or PermutedDimsArray functions. My goal was to find the cost for multiplying a transposed array, and I encountered a behavior of transpose I cannot expl…

---

## [Passing sub-array by reference / performance](https://discourse.julialang.org/t/passing-sub-array-by-reference-performance/22978)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 18\
**Last updated:** [April 10, 2019, 7:01pm UTC](https://discourse.julialang.org/t/passing-sub-array-by-reference-performance/22978 "2019-04-10T19:01:48Z")

</div>

In trying to pass subarrays by reference in a computer intensive code, I found the “view” function, which appeared to be the solution. However, I see important performance issues using that option relative to passing the…

---

## [Iterator Invalidation](https://discourse.julialang.org/t/iterator-invalidation/22979)

<div class="topic-metadata">

**Author:** [@JaredCrean2](https://discourse.julialang.org/u/JaredCrean2)\
**Replies:** 5\
**Last updated:** [April 10, 2019, 6:05pm UTC](https://discourse.julialang.org/t/iterator-invalidation/22979 "2019-04-10T18:05:27Z")

</div>

I wrote some code that looks like for val in values # values is a Vector idx = findfirst(values, val) values\[idx\] = 0 if too many zeros in values ... move nonzero values to beginning of vector resize!(val…

---

## [Selecting Parameters Boundary using "ODELocalSensitivityProblem"](https://discourse.julialang.org/t/selecting-parameters-boundary-using-odelocalsensitivityproblem/22881)

<div class="topic-metadata">

**Author:** [@pandeysudan27](https://discourse.julialang.org/u/pandeysudan27)\
**Replies:** 2\
**Last updated:** [April 10, 2019, 4:43pm UTC](https://discourse.julialang.org/t/selecting-parameters-boundary-using-odelocalsensitivityproblem/22881 "2019-04-10T16:43:22Z")

</div>

I am trying for local sensitivity analysis using “ODELocalSensitivityProblem” from http://docs.juliadiffeq.org/latest/analysis/sensitivity.html#Example-solving-an-ODELocalSensitivityProblem-1. However, how do I set for p…

---

## [Getobjectivevalue does not return value of my objective function](https://discourse.julialang.org/t/getobjectivevalue-does-not-return-value-of-my-objective-function/23002)

<div class="topic-metadata">

**Author:** [@Y\_Li](https://discourse.julialang.org/u/Y_Li)\
**Replies:** 0\
**Last updated:** [April 10, 2019, 2:25pm UTC](https://discourse.julialang.org/t/getobjectivevalue-does-not-return-value-of-my-objective-function/23002 "2019-04-10T14:25:37Z")

</div>

using MatpowerCases using JuMP using Ipopt include("acopf\_input.jl") path = pwd()"/case.dat" casefilename, refbus, loadscale, thermalLimitscale, extras, mvaBase = readconfig(path) generators, generatorlist, buses, lines …

---

## [Collecting algebraic performance tricks](https://discourse.julialang.org/t/collecting-algebraic-performance-tricks/22992)

<div class="topic-metadata">

**Author:** [@theogf](https://discourse.julialang.org/u/theogf)\
**Replies:** 10\
**Last updated:** [April 10, 2019, 2:04pm UTC](https://discourse.julialang.org/t/collecting-algebraic-performance-tricks/22992 "2019-04-10T14:04:09Z")

</div>

There are many ways to dramatically improve performance by using some algebraic equivalencies, for example : tr(A\*B) == dot(A,B') diag(A\*B) == vec(sum(A.\*B',dims=2)) Do you know if there are ressources listing this ki…

---

## [Environment prompt in the REPL](https://discourse.julialang.org/t/environment-prompt-in-the-repl/16795)

<div class="topic-metadata">

**Author:** [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Replies:** 12\
**Last updated:** [April 10, 2019, 1:56pm UTC](https://discourse.julialang.org/t/environment-prompt-in-the-repl/16795 "2019-04-10T13:56:59Z")

</div>

Hello, I’d like to know how I could change the julia\> prompt REPL when I activate a project. In the package manager prompt, the environments are indicated, but not when I go back to the REPL. I think it would be less co…

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

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