有一些问题,现在我已经阅读了以下内容:
我已经尝试在我的桌面上安装boost,并按照链接方面建议的帖子完成.我有以下代码:
#include <boost/python.hpp>
#include <Python.h>
using namespace boost::python;
Run Code Online (Sandbox Code Playgroud)
现在我尝试连接以下内容:
g++ testing.cpp -I /usr/include/python2.7/pyconfig.h -L /usr/include/python2.7/Python.h
-lpython2.7
Run Code Online (Sandbox Code Playgroud)
我也尝试了以下内容:
g++ testing.cpp -I /home/username/python/include/ -L /usr/include/python2.7/Python.h -lpython2.7
Run Code Online (Sandbox Code Playgroud)
我一直收到以下错误:
/usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such
file or directory
# include <pyconfig.h>
Run Code Online (Sandbox Code Playgroud)
我不知道我哪里错了.我确实安装了boost.python,链接只是一个问题?
我在本地使用第三方库,我使用他们提供的步骤安装了所有内容.
composer require了包并运行了更新.这安装在vendor文件夹中.providerin中config/app,也作为别名..php artisan vendor:publish --provider="Spatie\LaravelAnalytics\LaravelAnalyticsServiceProvider"了成功创建的配置文件,我没有遇到任何问题.然后我上传到生产环境并不断获取Class 'LaravelAnalytics' not found,我似乎无法弄清楚问题..
我跑了 php artisan vendor:publish --provider="Spatie\LaravelAnalytics\LaravelAnalyticsServiceProvider"
但是我继续说道:Nothing to publish for tag [].这导致我认为这可能是问题,因为包裹没有发布.
我的本地环境是Ubuntu,我的生产环境是CentOS.如果我在我的生产环境中尝试将CD放入该目录,它说无法找到.
因此,对于我如何添加不提取此软件包的提供程序,这可能是一个问题吗?
尝试在Python中计算SVD以找到频谱中最重要的元素,并创建一个仅包含最重要部分的矩阵.
在python我有:
u,s,v = linalg.svd(Pxx, full_matrices=True)
Run Code Online (Sandbox Code Playgroud)
这样可以得到3个矩阵; 其中"s"包含与u,v相对应的大小.
为了构造一个包含信号的所有重要部分的新矩阵,我需要捕获"s"中的最高值并将它们与"u"和"v"中的列匹配,得到的矩阵应该给我数据中最重要的部分.
问题是我不知道如何在Python中执行此操作,例如,如何在"s"中找到最高数字并选择"u"和"v"中的列以创建新矩阵?
(我是Python和numpy的新手)所以任何帮助都将非常感激
编辑:
import wave, struct, numpy as np, matplotlib.mlab as mlab, pylab as pl
from scipy import linalg, mat, dot;
def wavToArr(wavefile):
w = wave.open(wavefile,"rb")
p = w.getparams()
s = w.readframes(p[3])
w.close()
sd = np.fromstring(s, np.int16)
return sd,p
def wavToSpec(wavefile,log=False,norm=False):
wavArr,wavParams = wavToArr(wavefile)
print wavParams
return mlab.specgram(wavArr, NFFT=256,Fs=wavParams[2],detrend=mlab.detrend_mean,window=mlab.window_hanning,noverlap=128,sides='onesided',scale_by_freq=True)
wavArr,wavParams = wavToArr("wavBat1.wav")
Pxx, freqs, bins = wavToSpec("wavBat1.wav")
Pxx += 0.0001
U, s, Vh = linalg.svd(Pxx, full_matrices=True)
assert np.allclose(Pxx, np.dot(U, np.dot(np.diag(s), Vh))) …Run Code Online (Sandbox Code Playgroud) 我一直在寻找一个更优化的解决方案,我似乎无法找到一个.
假设我有一个向量:
std::vector<double> vars = {1, 2, 3}
我想表演1 * 2 * 3我知道我可以做以下事情:
int multi = 1;
for(int i = 0; (i < vars.size()-1); i++)
{
multi *= vars[i];
}
Run Code Online (Sandbox Code Playgroud)
但是,有更多的"C++ 11"方法吗?我真的想用这个来做lambda,所以我可以计算向量的乘法(乘积),而不需要在类中有另一个函数,我宁愿在函数内部计算它.
所以我有以下Vue文件:
<template>
<li class="notifications new">
<a href="" data-toggle="dropdown"> <i class="fa fa-bell-o"></i> <sup>
<span class="counter">0</span>
</sup>
</a>
<div class="dropdown-menu notifications-dropdown-menu animated flipInX">
<ul v-for="notification in notifications" @click="" class="notifications-container">
<li>
<div class="img-col">
<div class="img" style="background-image: url('assets/faces/3.jpg')"></div>
</div>
</li>
</ul>
</div>
</li>
</template>
<script>
export default {
data: function() {
return {
notifications: [],
message: "",
}
},
methods: {
loadData: function() {
Vue.http.get('/notifications').then(function(response) {
console.log(response.data);
//this.notifications = response.data;
//this.notifications.push(response.data);
this.message = "This is a message";
console.log(this.message);
});
},
},
mounted() {
this.loadData(); …Run Code Online (Sandbox Code Playgroud) 我有两个线程,并且,我希望一个线程运行10秒,然后让这个线程停止,而另一个线程执行,然后第一个线程再次启动; 这个过程重复进行.所以,例如
from threading import Thread
import sys
import time
class Worker(Thread):
Listened = False;
def __init__(self):
while 1:
if(self.Listened == False):
time.sleep(0)
else:
time.sleep(20)
for x in range(0, 10):
print "I'm working"
self.Listened = True
class Processor(Thread):
Listened = False;
def __init__(self):
# this is where I'm confused!!
Worker().start()
Processer().start()
Run Code Online (Sandbox Code Playgroud)
(PS我已正确缩进,但是,似乎有点搞砸了)
基本上,我想要的是:
工作线程工作10秒钟(或左右)然后停止,"处理器"启动,一旦处理器处理了"工作"线程的最后一次运行的数据,它就重新启动"工人"搞砸了.我没有必要从当前位置重新启动"worker"线程,它可以从头开始.
有没有人有任何想法?
这是一个跟进问题:C++ - 开发自己的std :: count_if版本?
我有以下功能:
// vector for storing the file names that contains sound
std::vector<std::string> FilesContainingSound;
void ContainsSound(const std::unique_ptr<Signal>& s)
{
// Open the Wav file
Wav waveFile = Wav("Samples/" + s->filename_);
// Copy the signal that contains the sufficient energy
std::copy_if(waveFile.Signal().begin(), waveFile.Signal().end(),
FilesContainingSound.begin(), [] (const Signal& s) {
// If the energy bin > threshold then store the
// file name inside FilesContaining
}
}
Run Code Online (Sandbox Code Playgroud)
但对我来说,我只需要在lambda表达式中捕获字符串"filename",因为我只会使用它.我只需要访问waveFile.Signal()以进行分析.
有人有什么建议吗?
编辑:
std::vector<std::string> FilesContainingSound;
std::copy_if(w.Signal().begin(), w.Signal().end(),
FilesContainingSound.begin(), …Run Code Online (Sandbox Code Playgroud) 我正在尝试在nodeJS中dotenv(https://github.com/motdotla/dotenv)来存储我正在使用的oauth服务器的客户端秘密值。
我的.env文件如下所示:
clientSecret=imU86A3oPiZlyOhZybShraP377ers0MvowBaizEQ
在 NodeJS 文件中,我有以下内容:
passport.use(new PasswordGrantStrategy({
tokenURL: 'WEBSITE_ADDRESS',
clientID: "2",
clientSecret: process.env.clientSecret,
grantType: "password",
},
Run Code Online (Sandbox Code Playgroud)
问题是我得到一个Token Error但是,如果我将其更改为以下内容:
passport.use(new PasswordGrantStrategy({
tokenURL: 'WEBSITE_ADDRESS',
clientID: "2",
clientSecret: "imU86A3oPiZlyOhZybShraP377ers0MvowBaizEQ",
grantType: "password",
},
Run Code Online (Sandbox Code Playgroud)
这样就可以完美地工作了。我不明白问题是什么,我尝试将其转换为字符串,但没有这样的运气。
这些值都是匹配的,我将它们打印出来,它们是相同的。
我有以下表格,带有字段:
您可以添加多行,然后将此数据发送到控制器。
我想要的是:
假设页面上当前有两行输入,因此输出将类似于:
$rates => array(2)
0 => [
"from" => 1,
"to" => 2,
"price" => 10
],
1 => [
"from" => 1,
"to" => 2,
"price" => 10
]
Run Code Online (Sandbox Code Playgroud)
我尝试执行以下操作(HMTL):
<input type="text" name="rates[]" placeholder="Enter rate from"
autocomplete="off" class="form-control">
Run Code Online (Sandbox Code Playgroud)
但这只是给了我一个包含所有值的 6 数组,而无法知道顺序。我还尝试了以下方法:
<input type="text" name="rates[]['from']" placeholder="Enter rate from"
autocomplete="off" class="form-control">
<input type="text" name="rates[]['to']" placeholder="Enter rate to"
autocomplete="off" class="form-control">
<input type="text" name="rates[]['price']" placeholder="Enter rate price"
autocomplete="off" class="form-control">
Run Code Online (Sandbox Code Playgroud)
这不会产生我需要的结果。是否可以使用 HTML 和 PHP 做我想做的事情?
我只是想知道是否有一个简单,快速的方法是在矢量中插入矢量矢量的元素.例如:
std::vector<std::vector<double> > vals {
{1, 2, 3, 4, 5, 6},
{1, 2, 3, 4, 5, 6}
};
std::vector<double> myvector;
Run Code Online (Sandbox Code Playgroud)
那么myvector将包含:1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6
我已经尝试使用insert和push_back,但没有运气.
编辑:
我用过:
myvector.insert(vals.begin(), vals.end()); - 没有匹配的成员函数来调用'insert'