Quantcast
Channel: First steps - JuliaLang
Browsing all 2795 articles
Browse latest View live

Efficient way to avoid repetitive functions with multiple methods

@Elmer_Cusipuma wrote: I have a structure which has a function with many methods. struct shape type :: Symbol mtl :: String t :: Real A :: Float64 Asy :: Float64 Asz :: Float64 function...

View Article


Reshaping Arrays (DimensionMismatch)

@ASF wrote: Hi - I have the following arrays: X = Shape (50562,19) theta = Shape (19,) im trying to do a simple dot product but i get the following error: DimensionMismatch(“first array has length...

View Article


What is difference between "a" and 'a'?

@Dito wrote: What does function sizeof() do? sizeof("a") 1 julia> length('a') 1 julia> sizeof('a') 4 julia> sizeof("∀") 3 julia> sizeof('∀') 4 julia> sizeof("🍎") 4 And if sizeof() gives...

View Article

Using zip() with count()

@j.copsey wrote: I’m trying to use count where the iterator is taken from zip. Here is the code I’ve written: function hamming(c, d) count((x,y) -> (x != y), zip(c,d)) end However, when this is run...

View Article

Parallel loop

@donquicote wrote: Hi, Can anyone help me to parallelize the following code? I’ve tried to look for how to parallelize nested loops in the documentation but I couldn’t find anything about it. Thank...

View Article


Print formatting

@ASF wrote: Python has options to reset the cursor position and flush output to prevent output from scrolling in the console e.g. print("\r this will be over written by the next line",flush=true) Is...

View Article

Sigmoid function in Julia

@hasanOryx wrote: I’m trying to write the sigmoid function as below, but did not work: function sigmoid(z::Array) return 1.0 ./ (1.0 + exp(-z)) end; Knowing that the below is working fine, but I’m...

View Article

Broadcast for Array of Array

@hasanOryx wrote: I’ve the below function sigmoid(z::Real) = one(z) / (one(z) + exp(-z)) And want to broadcast it for all the element of x, where: X = [ [1, 2, 3], [3, 4, 5], [5, 6, 7] ] I tried the...

View Article


Help with array multiplication

@hasanOryx wrote: I aware that to multiple arrays, dimensions should match as: A: array of (x,y) , B: array of (y,z) In Python below is working fine: X = np.array([ [0,0,1], [0,1,1], [1,0,1], [1,1,1]...

View Article


Image may be NSFW.
Clik here to view.

Where is my mistake in converting this python code into Julia

@hasanOryx wrote: I’m trying to convert the python code(left) into Julia (right), python code is working fine, but Julia code gave an error at the highlighted line l1_delta = ...: DimensionMismatch("A...

View Article

How to define a condition expression

@Lyupinpin wrote: Like if there exsis a file named “abc” then else end Posts: 3 Participants: 2 Read full topic

View Article

Predefined array too large

@squirrel wrote: I predefined a vector E to be the same size as vector D. E = typeof(D)(undef, length(D)) In most cases, I expect E to have the same number of elements as D, but I still want to be...

View Article

Images.jl not working with JuMP output in for loop

@amoghb13 wrote: I am trying to represent a matrix as black and white squares. Example: This works for me for one time. using Colors, Images y = [0.5 0.5; 0.7 0.3] imgg = Gray.(y) This does not work...

View Article


How to represent binary array (slot occupied = 1, slot open = 0) in the form...

@amoghb13 wrote: Hi I want to represent a binary (0-1) array in the form of an image. E.g. if A[1,1] = 1, then square [1,1[ would be represented as black colored square otherwise it will be...

View Article

Passing gradient to Optim

@ASF wrote: i have the following code: solution = Optim.minimizer(optimize(θ->J(X,θ),θ,g!,LBFGS()))) where X,θ are arrays and g! is the gradient function. I get the following error only when trying...

View Article


Image is upside down using Plots.plot

@helloBrisbane wrote: hi Guys, I am trying to use Plots.plot to save images in REPL on ubuntu. However it always save the picture upside down even if I have not do anything on the image yet. Please...

View Article

Multiple dispatch usage with named arguments

@Rajesh_Talluri wrote: Hi, I am trying to write a function which has multiple arguments. The argument maf could be a single value or a vector of length p. function simulate_data(; n::Int64 = 1000,...

View Article


Understanding specialization and parametric types

@rapus95 wrote: Right now I try to understand how specialization and parametric types interact. The following all came up when trying to design a sliding window iterator (iterator that shall return a...

View Article

Test a function modifies argument

@squirrel wrote: How should I write a @testset to verify that a function modifies its argument? For example, here is a function that is passed a vector (of Rationals) v and a row index row: function...

View Article

Printing to string from stream

@Rajesh_Talluri wrote: Hi, I am trying to get the output of a stream into a string. For example the highlight function outputs the result to an IO object, so I can open a file and write to it. I can...

View Article
Browsing all 2795 articles
Browse latest View live


Latest Images