试图计算R中矩阵的幂,我发现包expm实现了运算符%^%.
所以x%^%k计算矩阵的k次方.
> A<-matrix(c(1,3,0,2,8,4,1,1,1),nrow=3)
> A %^% 5
[,1] [,2] [,3]
[1,] 6469 18038 2929
[2,] 21837 60902 9889
[3,] 10440 29116 4729
Run Code Online (Sandbox Code Playgroud)
但令我惊讶的是:
> A
[,1] [,2] [,3]
[1,] 691 1926 312
[2,] 2331 6502 1056
[3,] 1116 3108 505
Run Code Online (Sandbox Code Playgroud)
不知何故,初始矩阵A已变为A%^%4 !!!
你如何执行矩阵功率操作?
是否可以在简单的ANSI C中为控制台输出着色?没有外部库?这可以在Windows,Linux或Mac OS X中完成吗?
如果我尝试使用特殊(北欧)字符创建一个选择,例如:
Select * from users where name like '%æ%'
Run Code Online (Sandbox Code Playgroud)
它只是选择所有用户而不是包含字母“æ”的用户。
我是否需要为数据库安装一些特殊的驱动程序,或者还有什么我遗漏的地方?
更新:
我使用的是 SQL Server 2008 数据库,排序规则设置为“SQL_Latin1_General_CP1_CI_AS”,数据字段是可为空的 nVarChar 数据类型。
这是一个C#桌面应用程序.DrawStyle我的属性ListBox设置为OwnerDrawFixed.
问题:我重写DrawItem以不同的字体绘制文本,它的工作原理.但是当我在运行时开始调整表单大小时,正确绘制了所选项目,但其余部分未重绘,导致文本看起来已损坏未选中的项目.
这是我的代码:
private void listDevices_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
string textDevice = ((ListBox)sender).Items[e.Index].ToString();
e.Graphics.DrawString(textDevice,
new Font("Ariel", 15, FontStyle.Bold), new SolidBrush(Color.Black),
e.Bounds, StringFormat.GenericDefault);
// Figure out where to draw IP
StringFormat copy = new StringFormat(
StringFormatFlags.NoWrap |
StringFormatFlags.MeasureTrailingSpaces
);
copy.SetMeasurableCharacterRanges(new CharacterRange[] {new CharacterRange(0, textDevice.Length)});
Region[] regions = e.Graphics.MeasureCharacterRanges(
textDevice, new Font("Ariel", 15, FontStyle.Bold), e.Bounds, copy);
int width = (int)(regions[0].GetBounds(e.Graphics).Width);
Rectangle rect = e.Bounds;
rect.X += width;
rect.Width -= width;
// draw IP …Run Code Online (Sandbox Code Playgroud) 一些流行语言(如Python和Ruby)具有本机,JVM和.Net CLR实现.C#是使用免费的Mono项目实现的.是否有任何实施F#的尝试?
是否可以从javascript检索现有cookie的创建或过期日期?如果是这样的话?
我重新安装了Windows并解压缩了Eclipse的新副本.尽管如此,我还是无法通过Subclipse访问ssh存储库.问题似乎与JavaHL有关,而Tigris网站的测试给出了NoClassDefError.虽然这可以被认为是一个软件问题,但我希望有人之前会遇到这个问题.有没有办法来解决这个问题?这很紧急.
PS:设置的东西使得Subclipse会在配置文件中查找转发到TortoiseSVN的PLink客户端的调用,而该客户端又获得了一个在Pageant中加载的密钥.
编辑:这是重新安装jdk后java -jar javahltests.jar的输出:
.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.
E.E.E.E.E.E.E.E.E.E
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0xffbadd11, pid=752, tid=656
#
# JRE version: 6.0_21-b06
# Java VM: Java HotSpot(TM) Client VM (17.0-b16 mixed mode, sharing windows-x86 )
# Problematic frame:
# C 0xffbadd11
#
# An error report file with more information is saved as:
# C:\\hs_err_pid752.log
#
# If you would like to submit a bug report, please visit:
# …Run Code Online (Sandbox Code Playgroud) 我通过get发送数据,我需要将它放入一个int数组,用于find.这是我的代码:
@found = Array.new
params['candidate'].each do |c|
@found << c.to_i
end
Run Code Online (Sandbox Code Playgroud)
我的网址看起来像这样
http://localhost:3000/export/candidate?candidate[]=3&candidate[]=4&commit=Export
Run Code Online (Sandbox Code Playgroud)
如果它有任何区别我将它用于此查找
@candidate = Candidate.find(:all, :conditions => ["candidates.id IN ?", @found])
Run Code Online (Sandbox Code Playgroud)
但是目前它没有把它放在一个真正的数组中因为我得到了这个错误
Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '4)' at line 1: SELECT * FROM `candidates` WHERE (candidates.id IN 4,2)
Run Code Online (Sandbox Code Playgroud)
数组周围缺少括号
谢谢,早上好!
亚历克斯
我和我这个时代的另一位开发人员最近从一台Core 2 Duo机器搬到了新的Core 2 Quad 9505; 两者都使用JDK 1.6.0_18运行Windows XP SP3 32位.
在这样做的时候,我们对一些时序/统计/度量聚合代码的自动单元测试很快就会失败,因为看起来似乎是从System.nanoTime()返回的荒谬值.
在我的机器上可靠地显示此行为的测试代码是:
import static org.junit.Assert.assertThat;
import org.hamcrest.Matchers;
import org.junit.Test;
public class NanoTest {
@Test
public void testNanoTime() throws InterruptedException {
final long sleepMillis = 5000;
long nanosBefore = System.nanoTime();
long millisBefore = System.currentTimeMillis();
Thread.sleep(sleepMillis);
long nanosTaken = System.nanoTime() - nanosBefore;
long millisTaken = System.currentTimeMillis() - millisBefore;
System.out.println("nanosTaken="+nanosTaken);
System.out.println("millisTaken="+millisTaken);
// Check it slept within 10% of requested time
assertThat((double)millisTaken, Matchers.closeTo(sleepMillis, sleepMillis * 0.1));
assertThat((double)nanosTaken, Matchers.closeTo(sleepMillis * 1000000, sleepMillis * 1000000 …Run Code Online (Sandbox Code Playgroud) 有人可以用JavaScript指导我的日期范围吗?
我想计算从今天开始的一个星期和一个月的日期范围; 即,如果今天是"2010年7月18日",本周的范围应为"2010年7月11日 - 2010年7月8日",本月应为"01/07/2010 - 18/07/2010" ".
感谢您提前的指导.