这是代码:
import java.io.*;
public class Bed {
private String bedfn;
private int bytes_snp;
private int nindiv;
private long bedsize;
private int nsnp;
private byte[] magicBytes;
public Bed(String bedfn, int bytes_snp, int nindiv) {
this.bedfn = bedfn;
this.bytes_snp = bytes_snp;
this.nindiv = nindiv;
bedsize = (new File(bedfn)).length();
nsnp = (int) ((bedsize - 3) / bytes_snp);
///////////////////////////////////////
magicBytes = new byte[] {0x6c, 0x1b, 0x01};
}
//...
public OutputStream writeBytes(OutputStream fileStream, byte[] bytes) {
try{
fileStream.write(bytes);
} catch (IOException e) {
e.printStackTrace();
} …Run Code Online (Sandbox Code Playgroud) 这是代码:
import processing.core._
import PConstants._
import PApplet._
class PApp extends PApplet{
args = Array("PApp")
var x: Float = 0.0f
var y: Float = 0.0f
var z: Float = 0.0f
override def setup(): Unit = {
size(200, 200, "P3D")
x = width/2
y = height/2
z = 0
}
override def draw(): Unit = {
translate(x, y, z)
rectMode(CENTER)
rect(0, 0, 10, 10)
z += 1
}
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试运行它(intellij中的ctrl-shift-R),我会收到以下消息:
Usage: PApplet [options] <class name> [sketch args]
See the Javadoc for PApplet …Run Code Online (Sandbox Code Playgroud) 从手册页的seek在R:
不鼓励在Windows上使用搜索.我们在Windows文件定位实现中发现了很多错误,建议用户自行承担使用它的风险,并要求不要浪费R开发人员的时间来处理有关Windows缺陷的错误报告.
对于具有NTFS文件系统的Windows的现代版本,这仍然适用吗?
码:
let x: String = ("abc".substringFromIndex(1))
print(x)
//func tail(s: String) -> String {
// return s.substringFromIndex(1)
//}
//print(tail("abcd"))
Run Code Online (Sandbox Code Playgroud)
这按预期工作。
但是,如果我取消对最后4行的注释,那么我得到:
Error: cannot convert value of type 'Int' to expected argument type 'Index' (aka 'String.CharacterView.Index')
Run Code Online (Sandbox Code Playgroud)
真奇怪。
码:
import scala.concurrent.Future
import scala.util.{Failure, Success}
import scala.concurrent.ExecutionContext.Implicits.global
/**
* Created by IDEA on 12/23/16.
*/
object Demo extends App {
val fut = Future {
Thread.sleep(100)
21 + 21
}
val f = Future { 5 }
Thread.sleep(200)
val fut1 = fut.map(_ + 1)
println(fut1) // Future(Success(43))
println(fut1.value) // Some(Success(43))
println(fut.map(_ + 1).value) // None
fut.map(_ + 1).onComplete {
case Success(v) => println(v)
case Failure(e) => println(e)
} // 43
(for {
x <- Future {Thread.sleep(100); 21 + 21} …Run Code Online (Sandbox Code Playgroud) 我在编译时使用了以下选项(在Make.user文件中):
USE_INTEL_MKL = 1
USE_INTEL_MKL_FFT = 1
Run Code Online (Sandbox Code Playgroud)
为了确保它确实与mkl相关联,我尝试了以下操作:
~$ ldd /home/kaiyin/opt/julia-0.6.0-rc1/julia
linux-vdso.so.1 => (0x00007ffe85fec000)
libjulia.so.0.6 => not found
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f748579e000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f7485596000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7485379000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7484faf000)
/lib64/ld-linux-x86-64.so.2 (0x0000563aa3d8e000)
Run Code Online (Sandbox Code Playgroud)
似乎与mkl没有任何关系。另外,“未找到” libjulia.so。有什么建议么?
顺便说一句,我可以毫无问题地开始朱莉娅的代表:
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| …Run Code Online (Sandbox Code Playgroud) 我想在每次退出bash时执行一些命令,但找不到办法.当你注销时有一个〜/ .bash_logout文件,但通常我们使用交互式shell而不是登录shell,所以这对于这个目的来说并不是很有用.
有没有办法做到这一点?谢谢!
以下是一个示例:
x = data.frame(x1=1:3, x2=2:4, x3=3:5)
x
# x1 x2 x3
# 1 1 2 3
# 2 2 3 4
# 3 3 4 5
x[2, 1] = NA
x[3, 2] = NA
complete.cases(x)
# [1] TRUE FALSE FALSE
x[complete.cases(x), , drop=FALSE]
# x1 x2 x3
# 1 1 2 3
Run Code Online (Sandbox Code Playgroud)
如果改为完整的情况,我想过滤完整的变量(列)?在上面的例子中,它应该是这样的:
x[,3,drop=FALSE]
# x3
# 1 3
# 2 4
# 3 5
Run Code Online (Sandbox Code Playgroud) 我有这样的事情:
class TransMach:
def __init__(self, machfile, snpfile):
self.machfile = machfile
self.snpfile = snpfile
def __translines(self):
fobj = open(self.machfile)
lines = (l.strip().split()[2] for l in fobj)
tlines = zip(*lines)
return tlines
Run Code Online (Sandbox Code Playgroud)
使用生成器是为了避免将整个文件读入内存,但有时读取整个文件正是所需的(即列表理解).如果没有太多额外的代码,我怎么能改变这种行为呢?目标是能够在这两种模式之间进行选择.我听说python有一些叫做描述符的功能,它可以用来修改函数而不需要触及函数的主体,在这种情况下它是否合适?如果是的话,应该如何在这里使用?
这是我采购的cpp文件sourceCpp:
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
// [[Rcpp::export]]
List mylm(NumericVector yr, NumericMatrix Xr) {
int n = Xr.nrow(), k = Xr.ncol();
arma::mat X(Xr.begin(), n, k, false); // reuses memory and avoids extra copy
arma::colvec y(yr.begin(), yr.size(), false);
arma::colvec coef = arma::solve(X, y); // fit model y ~ X
arma::colvec resid = y - X*coef; // residuals
double sig2 = arma::as_scalar( arma::trans(resid)*resid/(n-k) );
// std.error of estimate
arma::colvec stderrest = arma::sqrt( sig2 * arma::diagvec( arma::inv(arma::trans(X)*X)) );
return …Run Code Online (Sandbox Code Playgroud)