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 ArticleReshaping 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 ArticleWhat 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 ArticleUsing 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 ArticleParallel 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 ArticlePrint 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 ArticleSigmoid 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 ArticleBroadcast 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 ArticleHelp 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 ArticleWhere 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 ArticleHow 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 ArticlePredefined 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 ArticleImages.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 ArticleHow 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 ArticlePassing 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 ArticleImage 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 ArticleMultiple 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 ArticleUnderstanding 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 ArticleTest 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 ArticlePrinting 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