我正在玩一棵红黑树:
-- Taken from Okasaki 1999
module RedBlackTree where
--node coloring data
--a node is R (red) or B (black)
data Color = R | B
--tree constructor
--a RBT can be E (empty) or be T (a non empty tree)
data RBT e = E | T Color (RBT e) e (RBT e)
--set operations on tree
type Set a = RBT a
--define an empty set
empty :: Set e
empty = E
--define a member of a …Run Code Online (Sandbox Code Playgroud) 我通过编写点积计算器熟悉CUDA.我想用大数组测试它来进行时序研究,以测试两种不同的方法来收集矢量和.但是,当数组大小超过1024时,我会收到错误.我不太确定问题的来源.该卡是GTX460M,配备1.5GB内存.我正在使用该卡进行显示(这是一台笔记本电脑).除此之外,我不确定问题可能来自哪里.
这是nvcc编译行:
nvcc D:\Research\CUDA\TestCode\test_dotProduct_1.cu --use_fast_math --gpu-architecture sm_13 --compiler-bindir="D:\Programming\VisualStudio\2010express\VC\bin" --machine 32 -o multi_dot.exe
Run Code Online (Sandbox Code Playgroud)
我似乎也遇到了64位编译的问题,但这是另一个问题
以下是1024大小的数组的输出:
主机计算:357389824.000000
DEV PARA CALCULATION:357389824.000000
DEV SERI CALCULATION:357389824.000000
以下是大小为2048的数组的输出:
主机计算:2861214720.000000
DEV PARA CALCULATION:-1.#INF00
DEV SERI CALCULATION:-1.#INF00
这是我的代码:
/*Code for a CUDA test project doing a basic dot product with doubles
*
*
*
*/
#include <stdio.h>
#include <cuda.h>
__global__ void GPU_parallelDotProduct(double *array_a, double *array_b, double *array_c){
array_c[threadIdx.x] = array_a[threadIdx.x] * array_b[threadIdx.x];
}
__global__ void GPU_parallelSumVector(double *vector, double *sum, int base){
sum[threadIdx.x + blockIdx.x] = vector[blockIdx.x + threadIdx.x …Run Code Online (Sandbox Code Playgroud) 假设我有一个字母:
A = ['A', 'T', 'C', 'G']
Run Code Online (Sandbox Code Playgroud)
我想生成长度为n(n-mer)的所有可能组合.例如n=2: AA, AT, ..., GG.为了让事情变得有趣,我正在尝试以动态方式使用列表推导来生成这些内容.这在python中可能吗?唯一明显的路径是eval()动态使用并生成所需的字符串.但是,我很好奇,看看是否有一个不那么笨重的方法.
我下载了 bioconductor 并尝试安装一个安装成功的包(“limma”),但是当我尝试更新 bioconductor 时,我不断收到与无效编译器选项相关的错误。它似乎特定于 gcc,gfortran 软件包安装没有问题。
这是输出:
[xxx]$ su -c 'R'
Password:
R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-redhat-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' …Run Code Online (Sandbox Code Playgroud) 我已经很久没和C一起工作了,因此我忘记了关于C如何工作的尴尬.我正在尝试创建一个标头'arrayUtils.h'和一个相应的'arrayUtils.c',我在其中定义了原型函数.然后我试图在第二个.c文件中调用其中一个函数
标题内容:
#define _OUT_OF_RANGE_ = NAN
#ifndef INT_ALLOCATE_H
#define INT_ALLOCATE_H
int * allocIntArray(const int size);
#endif
#ifndef INT_ACCESS_H
#define INT_ACCESS_H
int accessIntArray(const int index, const int * array, const bool checked);
#endif
#ifndef INT_FREE_H
#define INT_FREE_H
int freeIntArray(int * array);
#endif
Run Code Online (Sandbox Code Playgroud)
标题来源:
/* Allocates an array of integers equal to length size
* Args: int size: length of the array
* Return: Allocated array
*/
int * allocIntArray(const int size){
/*Assert that size of array is greater than zero*/
if(size …Run Code Online (Sandbox Code Playgroud) lambda如果x等于零,我想使用a 将x加1.我尝试了以下表达式:
t = map(lambda x: x+1 if x==0 else x, numpy.array())
t = map(lambda x: x==0 and x+1 or x, numpy.array())
t = numpy.apply_along_axis(lambda x: x+1 if x==0 else x, 0, numpy.array())
Run Code Online (Sandbox Code Playgroud)
每个表达式都返回以下错误:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Run Code Online (Sandbox Code Playgroud)
我的理解map(),并numpy.apply_along_axis()是,它会采取一些功能,并将其应用到数组的每个值.从错误看来,lambda似乎被评估为x=array,而不是数组中的某些值.我究竟做错了什么?
我知道我可以编写一个函数来完成这个,但我想更熟悉python的函数编程方面.