小编Pie*_*BdR的帖子

Linux下使用Atlas在numpy中的线程错误

我有一个使用在Linux机器上运行的多进程模块的多进程(不是多线程!)应用程序.这个应用程序使用该numpy.linalg.solve函数,如果我尝试创建许多进程,那么我得到错误:

assertion !pthread_create( &(ROOT->pid), ATTR, ROOT->fun, ROOT ) failed, line 84 of file /build/buildd-atlas_3.8.4-9-amd64-jk6dgk/atlas-3.8.4/build/atlas-base/../..//src/pthreads/misc/ATL_thread_tree.c
Run Code Online (Sandbox Code Playgroud)

请注意,在我开始使用函数之前numpy.linalg,我没有遇到任何问题.

知道问题可能是什么?

编辑:我试过用scipy.linalg.solve,问题是一样的!

编辑:通过用blas替换地图集,问题就消失了.所以看来这个问题确实存在于地图集中

linux runtime-error numpy multiprocessing atlas

5
推荐指数
1
解决办法
1516
查看次数

重载C++模板化函数

我认为以下代码应该工作,但g ++和clang ++都返回完全相同的错误(虽然Visual C++ 2012没有).

#include <iostream>
#include <tuple>

template <int N, typename T>
struct A { };

template <typename Tuple>
double result(const Tuple& t, const A<0, typename std::tuple_element<0, Tuple>::type>& a)
{
  return 0;
}

template <typename Tuple>
double result(const Tuple& t, const A<std::tuple_size<Tuple>::value-1,
                                      typename std::tuple_element<std::tuple_size<Tuple>::value-1,Tuple>::type>& a)
{
  return 1;
}

template <typename Tuple, int N>
double result(const Tuple& t, const A<N, typename std::tuple_element<N, Tuple>::type>& a)
{
  return 0.5;
}

int main()
{
  auto a = std::make_tuple(0, 1, 2., 3., …
Run Code Online (Sandbox Code Playgroud)

c++ templates overloading overload-resolution c++11

5
推荐指数
2
解决办法
318
查看次数

禁止对LISP中未使用的函数参数发出警告

在lisp中,我需要定义一组函数,所有函数都具有相同数量的参数.但是,这些函数可能会也可能不会使用所有参数,从而导致出现警告消息.例如:

(defun true (X Y) X)
[...]
; caught STYLE-WARNING:
;   The variable Y is defined but never used.
Run Code Online (Sandbox Code Playgroud)

有没有办法警告编译器是有意的?

lisp arguments function common-lisp suppress-warnings

5
推荐指数
1
解决办法
1788
查看次数

初始化模板内部类的静态成员

我在类模板中初始化静态成员所需的语法有问题.这是代码(我试图尽可能地减少它):

template <typename T>
struct A
{
  template <typename T1>
  struct B
  {
    static T1 b;
  };

  B<T> b;
  typedef B<T> BT;
  T val() { return b.b; }
};

template <typename T>
T A<T>::BT::b;

struct D
{
  D() : d(0) {}
  int d;
};

int main()
{
  A<D> a;
  return a.val().d;
}
Run Code Online (Sandbox Code Playgroud)

有了g++,我得到的错误是:

error: too few template-parameter-lists
Run Code Online (Sandbox Code Playgroud)

有任何想法如何初始化b?

请注意,我想保留typedef,就像在我的真实代码中一样,B比这更复杂.

c++ static templates initialization

4
推荐指数
1
解决办法
1580
查看次数

static_cast和对指针的引用

任何人都可以告诉我为什么这不编译:

struct A { };
struct B : public A { };

int main()
{
  B b;
  A* a = &b;
  B* &b1 = static_cast<B*&>(a);
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

现在,如果你用以下方法替换静态强制转换:

B* b1 = static_cast<B*>(a);
Run Code Online (Sandbox Code Playgroud)

然后它确实编译.

编辑:显然编译器将处理A*B*作为独立类型,否则这将起作用.问题更多的是为什么这是可取的?

c++ pointers reference const-cast

4
推荐指数
1
解决办法
1653
查看次数

scanf_s抛出异常

为什么以下代码scanf_s在输入要放入结构的数字后到达第二个时抛出异常.

这绝不代表完整的链表实现.

scanf_s输入值后,不确定如何进入下一个?有任何想法吗?

编辑:更新后的代码与建议的解决方案,但仍获得了AccessViolationException第一之后scanf_s

码:

struct node
{
    char name[20];
    int age;
    float height;
    node *nxt;
};

int FillInLinkedList(node* temp)
{

int result;
temp = new node;

printf("Please enter name of the person");
result = scanf_s("%s", temp->name);

printf("Please enter persons age");
result = scanf_s("%d", &temp->age); // Exception here...

printf("Please enter persons height");
result = scanf_s("%f", &temp->height);

temp->nxt = NULL;
if (result >0)
    return  1;
 else return 0;
}

// calling code

int main(array<System::String ^> …
Run Code Online (Sandbox Code Playgroud)

windows exception visual-c++

3
推荐指数
1
解决办法
1750
查看次数

强制mingw32-make忽略sh

我注意到,如果PATH中存在sh.exe,那么mingw32-make将使用它来启动命令.但如果不是,那么它将使用cmd.exe.问题是两个应用程序都完全不兼容,并且没有办法创建makefile以便兼顾两者.

有没有办法让mingw32-make始终使用cmd.exe?或者创建一个环境迫使mingw32-make忽略这个sh.exe?

windows mingw makefile

3
推荐指数
1
解决办法
806
查看次数

如何检查文件是否是DLL?

给定一个文件,我想检查这是一个DLL,还是共享对象(Linux)或dylib(Mac OS X),或者是不同的东西.我的主要兴趣是区分Linux和Mac OS X上的可执行文件和DLL.对于Windows,扩展应该足以解决我的问题.

我已经检查过神奇数字技术对Linux不起作用,因为可执行文件和共享对象都具有相同的编号.

c++ linux macos dll file-type

2
推荐指数
1
解决办法
290
查看次数

展开返回累加器的最后一个状态

unfoldHaskell中的函数非常便于创建列表.它的定义是:

unfold :: (b -> Maybe (a, b)) -> b -> [a]
Run Code Online (Sandbox Code Playgroud)

但我想得到累加器的最后一个值.可能的实现是:

unfoldRest :: (b -> Maybe (a, b)) -> b -> ([a], b)
unfoldRest fct ini = go fct ini []
  where
    go f s acc =
      case f s of
        Nothing -> (acc, s)
        Just (a, b) -> go f b (acc ++ [a])
Run Code Online (Sandbox Code Playgroud)

但我想知道是否有办法用现有的功能来做.最后这个:

countDown 0 = Nothing
countDown n = Just (n, n-1)
unfoldRest countDown 10
Run Code Online (Sandbox Code Playgroud)

将返回:

([10,9,8,7,6,5,4,3,2,1],0)
Run Code Online (Sandbox Code Playgroud)

因为迭代在达到累加器值时停止0.

haskell pointfree unfold

2
推荐指数
1
解决办法
497
查看次数