fo

IndexError: index 1 is out of bounds for axis 0 with size 1/ForwardEuler

匿名 (未验证) 提交于 2019-12-03 08:42:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am numerically solving for x(t) for a system of first order differential equations. The system is: dy/dt=(C)\*[(-K\*x)+M*A] I have implemented the Forward Euler method to solve this problem as follows: Here is my code: import matplotlib import numpy as np from numpy import * from numpy import linspace from matplotlib import pyplot as plt C=3 K=5 M=2 A=5 #------------------------------------------------------------------------------ def euler (f,x0,t): n=len (t) x=np.array ([x0*n]) for i in xrange (n-1): x[i+1] = x[i] + ( t[i+1] - t[i] ) *

What is the proper PInvoke signature for a function that takes var args?

匿名 (未验证) 提交于 2019-12-03 08:42:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: There is a native function: int sqlite3_config(int, ...); I would like to PInvoke to this function. Currently, I have this declaration: [DllImport("sqlite3", EntryPoint = "sqlite3_config")] public static extern Result Config (ConfigOption option); (Result and ConfigOption are enums of the form enum Result : int { ... } .) I am actually only interested in the single parameter version of this function and don't need the other args. Is this correct? I am also curious as to how you would declare the two argument form (perhaps it would take 2

PostgreSQL: Query has no destination for result data

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to fetch data from remote db by using dblink through function but getting an error "query has no destination for result data". I am using plpgsql language to do the same. Function : CREATE OR REPLACE FUNCTION fun() RETURNS text AS $$ begin select dblink_connect( 'port=5432 dbname=test user=postgres password=****'); WITH a AS ( SELECT * FROM dblink( 'SELECT slno,fname,mname,lname FROM remote_tbl' ) AS t (slno int, fname text, mname text, lname text) ) , b AS ( INSERT INTO temptab1 SELECT slno, name FROM a ) , c AS ( INSERT INTO

Is there a reference_wrapper<> for rvalue references?

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I wonder how the following can be done void f(string &&s) { std::string i(move(s)); /* other stuff */ } int main() { std::string s; bind(f, s)(); // Error. bind(f, move(s))(); // Error. bind(f, ref(s))(); // Error. } How can I pass an rvalue reference and store it as an rvalue reference (possibly wrapped) in the call wrapper? I know I can manually write up a class like std::reference_wrapper that has a conversion function to T&& , but I would rather want to avoid that and use Standard technology. I implemented it like AProgrammer recommends:

laravel fatal error for TestCase not found

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: http://localhost/laravel/app/tests/ExampleTest.php if i run laravel it shows the following error Fatal error: Class 'TestCase' not found in D:\xampp\htdocs\laravel\app\tests\ExampleTest.php on line 3 , any idea 回答1: Run following command in your project's root directory phpunit app/tests/ 回答2: You haven't really given much information to go on here, but the specific problem is probably that you don't have an autoloader (thus the TestCase class that PHP is expecting isn't actually loaded. The underlying problem in turn is likely that you're

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When I try to login I get an error: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) parametrs.yml: This file is auto-generated during the composer install parameters: database_driver: pdo_mysql database_host: localhost database_port: null database_name: sgce database_user: root database_password: mikem mailer_transport: smtp mailer_host: 127.0.0.1 mailer_user: null mailer_password: null locale: en secret: ThisTokenIsNotSoSecretChangeIt My OS is Debian Thanks for your help. [mysqld_safe] socket = /var

Python: NameError: global name 'foobar' is not defined

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have written the following class: class myClass(object): def __init__(self): pass def foo(self, arg1, arg2): pp = foobar(self, arg1, arg2) if pp: return 42 else return -666 def foobar(self, arg1, arg2): if arg1 == arg2: return 42 else: return None The logic is nonsensical - ignore it. What I am trying to so is to call an instance method from another instance method - and I am getting a NameError . I originally thought that this was due to foo() calling foobar() before it had been defined - but switching the order of the function

Installing Checkstyle-Plugin (7.2.0) for Eclipse Neon fails

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I tried to install the checkstyle-Plugin for my eclipse bundle Eclipse for Java Developers , by dragging the provided link from http://eclipse-cs.sourceforge.net/#!/ onto my Eclipse window. Unfortunately this results in the following error: An error occurred while collecting items to be installed session context was :( profile = epp . package . java , phase = org . eclipse . equinox . internal . p2 . engine . phases . Collect , operand =, action =). No repository found containing : osgi . bundle , net . sf . eclipsecs . branding ,

What does a 4-element tuple argument for 'bbox_to_anchor' mean in matplotlib?

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In the "Legend location" section of the "Legend guide" in the matplotlib website, there's a small script where line 9 is plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc= 3 , ncol=2, mode="expand", borderaxespad=0.) . All the tuples I've seen passed to bbox_to_anchor have 2 elements in it, but this one has 4. What does each element mean if the tuple passed has 4 elements? I was looking at it in the pyplot.legend docs , and it said something about bbox_transform coordinates. So I looked around and found matplotlib.transforms.Bbox with a

Codeforces Round #596 Div1 A~E题解

拈花ヽ惹草 提交于 2019-12-03 05:21:36
我好菜啊 A 题意: 定义p-二进制数为2^k-p,给出n和p,求用最小个数的p-二进制数来表示n 1<=n<=10^9,-1000<=p<=1000 题解: 猜结论,答案不会很大 n可以表示成kp+s的形式,枚举k,判断(n-kp)是否能用k个2的幂构成 画一下图可以发现,如果可以构成,那么满足(n-kp)的位数<=k<=n-kp (相当于把一颗二叉树上一个点变成两个) 证明答案不会很大: 首先(n-kp)的位数最多为30 ①p>=0 显然当k超过30后,如果不满足则之后也不满足 ②p<0 那么n-kp显然大于等于k code #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #define fo(a,b,c) for (a=b; a<=c; a++) #define fd(a,b,c) for (a=b; a>=c; a--) using namespace std; long long n,s; int p,i,j,k,l; bool pd(long long t) { long long T=t; int sum=0; while (T) { sum+=T&1; T>>=1; } if (s>=sum && s<=t) return