topics

全部话题 - 话题: multiarray
(共0页)
t****u
发帖数: 709
1
来自主题: DataSciences版 - 求助:关于2个python的题目
numberList=[5, 12, 0, 7, 2, 5, 10, 9, 12, 5]
def numRepeats(numberList, number):
return map(str, numberList).count(str(number))
print numRepeats(numberList, 5)
第一个一行就足够了
def diagonal(multiArray):
nrow = len(multiArray)
diagonalList = []
for i in xrange(nrow):
diagonalList.append(multiArray[i][i])
return diagonalList
print diagonal(multiArray)
对空 multiArray 也一样 没问题.
g****u
发帖数: 25
2
来自主题: DataSciences版 - 求助:关于2个python的题目
童鞋,你编程实在有点弱啊。。。
def numRepeats(numlist, num):
count = 0
for i in numlist:
if i == num: count += 1
return count

def diagonal(multiArray):
m = len(multiArray)
if m == 0: return []
n = len(multiArray[0])
diag = []
for i in range(min(m,n)):
diag.append(multiArray[i][i])
return diag
k*****6
发帖数: 26
3
有python比较熟练的朋友帮忙看下这两道题吗?万分感激。。
Do both of these problems using at least one loop each and not using any
special pre-existing functions that give you the answer with just one line
of code.
1. Make a function to count the number of times a specified number is
repeated in a list/array. That means that if we have a number list
numberList=[5, 12, 0, 7, 2, 5, 10, 9, 12, 5];
and we use the function call
numRepeats(numberList, 5)
we get the output: 3 --- meaning 5 occurs three times in numberList.... 阅读全帖
k*****6
发帖数: 26
4
来自主题: Programming版 - 求助:关于2个python的题目
有python比较熟练的朋友帮忙看下这两道题吗?万分感激。。
Do both of these problems using at least one loop each and not using any
special pre-existing functions that give you the answer with just one line
of code.
1. Make a function to count the number of times a specified number is
repeated in a list/array. That means that if we have a number list
numberList=[5, 12, 0, 7, 2, 5, 10, 9, 12, 5];
and we use the function call
numRepeats(numberList, 5)
we get the output: 3 --- meaning 5 occurs three times in numberList.... 阅读全帖
k*****6
发帖数: 26
5
来自主题: Computation版 - 求助:麻烦看看关于2个python的题目
有python比较熟练的朋友帮忙看下这两道题吗?万分感激。。
Do both of these problems using at least one loop each and not using any
special pre-existing functions that give you the answer with just one line
of code.
1. Make a function to count the number of times a specified number is
repeated in a list/array. That means that if we have a number list
numberList=[5, 12, 0, 7, 2, 5, 10, 9, 12, 5];
and we use the function call
numRepeats(numberList, 5)
we get the output: 3 --- meaning 5 occurs three times in numberList.... 阅读全帖
k*****6
发帖数: 26
6
来自主题: DataSciences版 - 求助:关于2个python的题目
有python比较熟练的朋友帮忙看下这两道题吗?万分感激。。
Do both of these problems using at least one loop each and not using any
special pre-existing functions that give you the answer with just one line
of code.
1. Make a function to count the number of times a specified number is
repeated in a list/array. That means that if we have a number list
numberList=[5, 12, 0, 7, 2, 5, 10, 9, 12, 5];
and we use the function call
numRepeats(numberList, 5)
we get the output: 3 --- meaning 5 occurs three times in numberList.... 阅读全帖
B*****g
发帖数: 34098
7
来自主题: DataSciences版 - 求助:关于2个python的题目
啥也不说了,你直接发包子吧
1
def numRepeats(numlist, num):
return numlist.count(num)
or
def numRepeats(numlist, num):
return sum(1 for s in numlist if s==num)
2
def diagonal(multiArray):
return [s[idx] for idx,s in enumerate(multiArray)]
f*******4
发帖数: 64
8
来自主题: JobHunting版 - 二维数组问题
boost.MultiArray
r*********r
发帖数: 3195
9
来自主题: Programming版 - opinions on boost.multiarray?
does anyone use it seriously? is it flexible ( can it be interfaced with
existing libs like GSL)?
any opinion is welcomed.
c*****z
发帖数: 182
10
来自主题: Programming版 - opinions on boost.multiarray?
i don't know the answer, but i want to ask a related questions:
anyone use the uBlas seriously?
better than gsl?
i saw it didn't even have svd decomposer
r*********r
发帖数: 3195
11
来自主题: Programming版 - opinions on boost.multiarray?
blas only contains low level operations, SVD shouldn't be in there.
p**o
发帖数: 3409
12
来自主题: Programming版 - In C++, how to do matrix computation?
现成的工业级别的开源实现这么多,为什么要执着于自己造轮子?
可以参考一下numpy/numeric对多维array的实现
https://github.com/numpy/numpy/tree/master/numpy/core/src/multiarray
(共0页)