我试图动态地从数组中获取第一个和最后一个元素.
所以,让我们假设数组有6个元素.
test = [1,23,4,6,7,8]
Run Code Online (Sandbox Code Playgroud)
如果我想要获得first and last = 1,8,23,7和4,6.有没有办法按此顺序获取元素?我看了几个Link Link2的问题.我接受了这些链接的帮助,我想出了这个原型..
#!/usr/bin/env python
import numpy
test = [1,23,4,6,7,8]
test1 = numpy.array([1,23,4,6,7,8])
len_test = len(test)
first_list = [0,1,2]
len_first = len(first_list)
second_list = [-1,-2,-3]
len_second = len(second_list)
for a in range(len_first):
print numpy.array(test)[[first_list[a] , second_list[a]]]
print test1[[first_list[a], second_list[a]]]
Run Code Online (Sandbox Code Playgroud)
但是如果你有超过6个元素,这个原型将无法扩展.所以,我想知道是否有办法动态获取这对元素.
谢谢!
HEADERS = schedule.h
default: papcmp
program.o: schedule.c $(HEADERS)
gcc -g -lnuma -lm -pthread schedule.c -lutil -lz -o schedule.o
program: schedule.o
gcc schedule.o -o papcmp
clean:
-rm -f schedule.o
-rm -f papcmp
-rm -f *.log dump.gz
Run Code Online (Sandbox Code Playgroud)
这是我第一次尝试创建一个make文件.看起来好像有错误.你能帮帮我吗?bold根据输出,输入的行有错误.
我正在用C编写一个函数来做一些计算.我希望以这种方式将其作为数组值返回给另一个函数.
455 calculated_val = calculation(value_perf);
358 int calculation(double* dataset){
359
360 double calculated[8] = {};
361 calculated[0] = dataset[7]/dataset[5];
362 calculated[1] = (dataset[0] + dataset[1] + dataset[2] - dataset[3] - dataset[4])/(dataset[5]);
363 calculated[2] = dataset[3]/dataset[5];
364 calculated[3] = dataset[6]/dataset[5];
365 calculated[4] = dataset[8]/dataset[5];
366 calculated[5] = dataset[9]/dataset[10];
367 calculated[6] = dataset[11]/dataset[5];
368 calculated[7] = dataset[12]/dataset[5];
369 return calculated;
370 }
Run Code Online (Sandbox Code Playgroud)
虽然,我这样做..我得到以下警告,我不明白.
369:2: warning: return makes integer from pointer without a cast [enabled by default]
369:2: warning: function returns address of …Run Code Online (Sandbox Code Playgroud) 如何将科学记数法转换为浮点数?这是我想要避免的一个例子:
Python 2.7.3 (default, Apr 14 2012, 08:58:41) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a=[78.40816326530613, 245068094.16326532]
>>> print a[0]/a[1]
3.19944395589e-07
>>> print float(a[0]/a[1])
3.19944395589e-07
>>> print float(a[0])/float(a[1])
3.19944395589e-07
Run Code Online (Sandbox Code Playgroud) 我目前正在学习ARM汇编语言;
为此,我试图将一些转换x86 code (AT&T Syntax)为ARM汇编(Intel Syntax)代码.
__asm__("movl $0x0804c000, %eax;");
__asm__("mov R0,#0x0804c000");
Run Code Online (Sandbox Code Playgroud)
从这个文档中,我了解到在x86中,堆结构的Chunk 1从0x0804c000开始.但是当我尝试同样的操作时arm,我收到以下错误:
/tmp/ccfNZp9F.s:174: Error: invalid constant (804c000) after fixup
Run Code Online (Sandbox Code Playgroud)
我假设问题是ARM只能加载32位指令.
Question 1: Any idea what would be the first chunk in case of ARM processors?
Question 2:
Run Code Online (Sandbox Code Playgroud)
从我之前的问题,我知道内存间接寻址是如何工作的.
下面写的片段是否做同样的工作?
movl (%eax), %ebx
LDR R0,[R1]
Run Code Online (Sandbox Code Playgroud)
我在用 ARMv7 Processor rev 4 (v7l)
我有一个ini与此类似的文件
[test]
foo=bar
Run Code Online (Sandbox Code Playgroud)
如果我们将此ini文件称为test1.ini
如何更改的值foo,以foobarbaz例如使用shell script。
我尝试了以下方法,但对我而言不起作用。我没有在ini文件中看到更新的更改。我该怎么写?
sed "/^foo=/s/=.*/=foobarbaz/" < test1.ini
Run Code Online (Sandbox Code Playgroud)
你有什么其他的建议
struct test
{
unsigned int test1;
unsigned char test2[4096];
unsigned int test3;
} foo
struct foobar
{
unsigned char data[4096];
}
Run Code Online (Sandbox Code Playgroud)
如果我想访问该结构,则说foo.test1,foo.test2 [4096]等。但是,当我希望以以下方式返回foo.test2中存在的数据时
pac.datafoo = foo.test2[4096];
unsigned char data[4096] = pac.datafoo;
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
error: initialization with "{...}" expected for aggregate object
Run Code Online (Sandbox Code Playgroud)
我在做什么错?
如何将列表列表转换为熊猫数据帧?
它不是coloumns的形式,而是行的形式.
#!/usr/bin/env python
from random import randrange
import pandas
data = [[[randrange(0,100) for j in range(0, 12)] for y in range(0, 12)] for x in range(0, 5)]
print data
df = pandas.DataFrame(data[0], columns=['B','P','F','I','FP','BP','2','M','3','1','I','L'])
print df
Run Code Online (Sandbox Code Playgroud)
例如:
data[0][0] == [64, 73, 76, 64, 61, 32, 36, 94, 81, 49, 94, 48]
Run Code Online (Sandbox Code Playgroud)
我希望它显示为行而不是coloumns.
目前它显示了这样的一些东西
B P F I FP BP 2 M 3 1 I L
0 64 73 76 64 61 32 36 94 81 49 94 48
1 57 …Run Code Online (Sandbox Code Playgroud) 我想为给定的名称绘制相应的x.我的意思是,因为foo它必须以[10,20,30]直方图的形式绘制,所有foo,bar,baz需要在同一个图中.(我不需要3d :))
import pylab as P
name = ['foo', 'bar', 'baz']
x = [[10,20,30],[40,50,60],[70,80,90]]
P.figure()
P.hist(x, 10, histtype='bar',
color=['crimson', 'burlywood', 'chartreuse'],
label=['Crimson', 'Burlywood', 'Chartreuse'])
P.show()
Run Code Online (Sandbox Code Playgroud) 问题主要在于profiling tools可用于ARM处理器 - 具体而言ARM v7; 我正在使用Linux
我打得四处Intel和AMD处理器,我知道他们有各种分析工具一样Perf,perfmon而valgrind这将让我监视各种计数器像retired instructions, cache misses, floating point unit, integral units, etc.
但是,我不知道是否ARM也支持这种分析工具.您知道可以在ARM处理器上使用的任何工具吗?
我搜索了ARM 参考手册,但未找到性能计数器列表.例如,在Intel处理器中,您可以在ref. manual和OProfile网页中找到它们.是否有手册或网页列出了performance monitoring countersfor 的列表ARM.
谢谢.