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

How to write copying & pasting code macro like `include`?

I want to copy & paste some code from other files. I know there is include but I think it is to include them to module’s global scope. I uses PyCall, and to implement Pythonic class, I need to...

View Article


Why does this constructor not work with 1 Int parameter?

Hi all, I am new to Julia and am experimenting with trying to create compact code. I created the following types: module Types export Percentage struct Percentage <: Real value::Float64...

View Article


Compute significance of Pearson Correlation Coefficient

Is there an option to compute the significance level (p-value) of the Pearson correlation coefficient using Statistics.cor ? This question was already asked before (here) but I couldn’t find more...

View Article

Why does 2^100 give 0?

As the title says, if I input a large enough computation into the REPL, it outputs 0, no matter whether I store the value or not. I understand that as I’m on a 64-bit system, my default type for...

View Article

EXCEPTION_ACCESS_VIOLATION when using LinearAlgebra.jl

I noticed this problem on my machine. I am thinking it is a installation issue and am wondering what else may be affected. Thanks in advance for any insight you might give in this matter. The problem...

View Article


Importing a binary file to a struct

Hi, I’m trying to port over some C++ & IDL code to Julia, the code basically opens up a binary file which has a 512 byte header described by a c++ struct. The reaminder of the file is a stack of...

View Article

Trouble with Dot Syntax: .* Works, .+ and sin. Do Not Work

Hello. This is my first post on here. I am doing some work with arrays for a small simulator. I have noticed that multiplication dot functions work fine but addition and trig functions do not. Example...

View Article

Parallelising a broadcast on a large-allocating function

I would like to parallelise a broadcast of a complicated function on my machine. Being new to parallel computing, I’m getting swamped and lost in all the posts and comments and open issues on it. My...

View Article


Why threadIdx().y shows some random value?

Hi, I am just new to CUDA and trying to learn. I tried to print thread id’s in x and y direction using the following code: using CUDA function test_kernel() @cuprintln("idx: %d, idy:...

View Article


User Defined Functions Using Input

This is my first program in Julia. I am most familiar with python, but as a math teacher I fell in love with being able to define a function like you would on paper (e.g. f(n) = 4n+4). I am trying to...

View Article

Adding elements to dictionaries?

Suppose I have a dictionary d = Dict("a"=->(1,2,3)) and I want to add an element with key "b" to the dictionary. The following works: merge!(d,Dict("b"=>(4,5,6))) However, this only seems to...

View Article

Image may be NSFW.
Clik here to view.

Is there a way to plot negative numbers on a log scale?

I know we are not supposed to be able to take the log of a negative number (or 0), but sometimes the scale is really useful. using Plots x = -10:0.01:10 y = x plot(x, y) plot(x, y, yaxis = log10.(y .+...

View Article

Image may be NSFW.
Clik here to view.

Excel to Julia

A bit of background - I am an actuary who is trying to learn Julia. In doing so, I am trying to move some of the models that I would usually make in Excel to Julia. I am stuck on one particular...

View Article


Loop and argument spacing style

I have some stylistic preferences listed below. I am wondering which I can keep using, and which I should change to conform to the community. I used the “Format Document” option in VSCode, and it made...

View Article

How to use a loop

This is a question related to some homework. I have to: Sort 25 assets according to the sum of returns over the last 22 days (R_{t-22}+R_{t-21}...+R_{t-1}). In (the evening of) period t-1 identify the...

View Article


BitArray{3} mesh

What is the recommended process to mesh a BitArray? The meshing method requires an isovalue. For a BitArray, an isovalue of 1, true or :true don’t seem to work: 0 faces are returned. Another method is...

View Article

Nightly build CI failing because rand(UnitRange) changed (when to care?)

The tests of a package of mine are failing with the nightly build of Julia, and I have found out that the reason is that the behavior of the random number generator changed when it is called with a...

View Article


Truncating and re-saving a Mesh (in .stl format)

I would like to load a .stl file of triangular facets, remove most from the mesh and save as a new .stl file. using FileIO, MeshIO mesh = load("test.stl") using GeometryBasics new_mesh =...

View Article

Julia, PiGPIO for Button control

I’m new to Julia and I’m just toying with the language on Raspberry Pi with the PiGPIO library. Is there doc on how to use the PiGPIO.callback function to monitor Edge transitions? I can see the...

View Article

ERROR: MethodError: no method matching decompose()

Hi, I have defined the following types: struct Percentage <: Real value::Float64 Percentage(x) = x < 0 ? new(0) : x > 1 ? new(1) : new(round(x, digits = 6)) end Base.show(io::IO,...

View Article
Browsing all 2795 articles
Browse latest View live