julia

How to resolve “UndefVarError: T not defined” in function signature

限于喜欢 提交于 2021-01-22 12:36:56
问题 I am trying to run (someone else's code) that looks like function f{T<:Number}(n::Int, alpha::T, beta::T) ... end When "using" that file I get UndefVarError: T not defined Stacktrace: [1] top-level scope at [file location]:[line number of function definition above] From what I've read in the documentation (https://docs.julialang.org/en/v1/base/numbers/), it looks like the syntax above is correct. Any idea why I'm getting this error? 回答1: This is old Julia syntax. This function should be re

Running .jl file from R or Python

若如初见. 提交于 2021-01-21 10:52:10
问题 I am new to Julia. I developed a few lines of code to get the results I needed from packages I was not able to find in Python or R. Now, I am trying to get this file to be easily accessible, and wrap the code in Python or R. Has anyone done this before? I have tried a few methods and have not found anything that has helped. The most simple way to do this would be just a few lines of code that calls the .jl file, runs it (which the code is then added to a .txt file from julia), and then alerts

Julia - Parallelism for Reading a Large file

℡╲_俬逩灬. 提交于 2021-01-21 10:17:05
问题 In Julia v1.1, assume that I have a very large text file (30GB) and I want parallelism (multi-threads) to read eachline, how can I do ? This code is an attempt to do this after checking Julia's documentation on multi-threading, but it's not working at all open("pathtofile", "r") do file # Count number of lines in file seekend(file) fileSize = position(file) seekstart(file) # skip nseekchars first characters of file seek(file, nseekchars) # progress bar, because it's a HUGE file p = Progress

Julia - Parallelism for Reading a Large file

让人想犯罪 __ 提交于 2021-01-21 10:16:56
问题 In Julia v1.1, assume that I have a very large text file (30GB) and I want parallelism (multi-threads) to read eachline, how can I do ? This code is an attempt to do this after checking Julia's documentation on multi-threading, but it's not working at all open("pathtofile", "r") do file # Count number of lines in file seekend(file) fileSize = position(file) seekstart(file) # skip nseekchars first characters of file seek(file, nseekchars) # progress bar, because it's a HUGE file p = Progress

Julia - Parallelism for Reading a Large file

為{幸葍}努か 提交于 2021-01-21 10:16:34
问题 In Julia v1.1, assume that I have a very large text file (30GB) and I want parallelism (multi-threads) to read eachline, how can I do ? This code is an attempt to do this after checking Julia's documentation on multi-threading, but it's not working at all open("pathtofile", "r") do file # Count number of lines in file seekend(file) fileSize = position(file) seekstart(file) # skip nseekchars first characters of file seek(file, nseekchars) # progress bar, because it's a HUGE file p = Progress

set the random seed in julia generator of random numbers

不羁岁月 提交于 2021-01-21 06:10:08
问题 I would like to do a couple of checkings using the random generator for normal distributed numbers in julia. So what I would like is to obtain the same sequence of pseudo-random numbers. Actually, I do random matrices, so I would like that both of my programs generate: A = randn(dim,dim) H = (A + A')/sqrt(2) the same H-matrix 回答1: Updated answer, for Julia 0.7 onwards. import Random Random.seed!(1234) dim = 5 A = randn(dim,dim) H = (A + A')/sqrt(2) Previous answer, for Julia 0.6 and earlier.

Issue importing PyPlot when submitting Julia file to cluster via Torque

跟風遠走 提交于 2021-01-05 20:31:46
问题 I am running some Julia code on my school's cluster. The .bps file which calls test_julia.jl is given below: 1 #!/bin/tcsh 2 3 #PBS -l walltime=24:00:00 4 #PBS -l nodes=1:ppn=1 5 #PBS -N test_julia 6 ##PBS -q normal 7 #PBS -q normal 8 #PBS -j oe 9 #PBS -o ./log/julia.${PBS_JOBID}.out 10 ##PBS -e ./log/julia.${PBS_JOBID}.err 11 ##PBS -m abe -M myemail@school.edu 12 #PBS -t 1-38 13 14 15 cd $PBS_O_WORKDIR 16 17 module load julia 18 19 julia /path/to/file/test_julia.jl 10 20 30 20 where 10, 20,

Julia alias in .bashrc not working correctly

梦想与她 提交于 2021-01-05 07:24:05
问题 I am running Julia on my university's cluster, which runs Red Hat Linux. The Julia download's path is /gsfs0/data/heathjo/Downloads/julia-1.5.3/bin When I run /gsfs0/data/heathjo/Downloads/julia-1.5.3/bin/julia Julia runs fine. However, I just want to type julia And have it run. I edited my .bashrc to include alias julia="/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin/julia" Running "julia", I now get the prompt CORRECT>.julia (y|n|e|a)? Running both .julia and julia results in julia: Command

Julia alias in .bashrc not working correctly

只愿长相守 提交于 2021-01-05 07:24:05
问题 I am running Julia on my university's cluster, which runs Red Hat Linux. The Julia download's path is /gsfs0/data/heathjo/Downloads/julia-1.5.3/bin When I run /gsfs0/data/heathjo/Downloads/julia-1.5.3/bin/julia Julia runs fine. However, I just want to type julia And have it run. I edited my .bashrc to include alias julia="/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin/julia" Running "julia", I now get the prompt CORRECT>.julia (y|n|e|a)? Running both .julia and julia results in julia: Command

Matlab中相见恨晚的命令(持续更新)

痞子三分冷 提交于 2021-01-05 04:06:10
  知乎上有个“有哪些让人相见恨晚的Matlab命令”的话题,很多答主提供的命令确实很实用,为了更方便大家的学习,我就知乎上的答案和我自己想到的都综合整理成了一篇文章,把我觉得很实用的指令整理出来。 知乎原答案链接 dbstop if error   如果运行出错,matlab会自动停在出错的那一行,并保存相关变量,非常好用的指令,谁用谁知道。 配合这个指令一起使用的是 dbup 和 dbdown ,这两个指令用于workspace间切换查看变量调试, dbup 是调到上层workspace, dbdown 是返回。 linkaxes   当使用 subplot 作图时,想要同时缩放多幅图,就可以使用该指令 figure; ax(1) = subplot(211); plot(sig1);ylim([-2,2]);grid on ax(2) = subplot(212); plot(sig2);ylim([-2,2]);grid on linkaxes(ax, 'xy'); %x轴和y轴都同步,也可以单独指定x或者y 效果如下: 在这里插入图片描述 yyaxis right   当我们要把两个波形画到一个图中时,大家都知道可以使用 hold on ,但如果两个波形的值域相差很大时,如下: 在这里插入图片描述   如果我们使用了 yyaxis right plot(sig1);