我有两个矩阵:A和B.
谢谢你回答我的问题!
帮助文件
#import <Foundation/Foundation.h>
#include <Accelerate/Accelerate.h>
@interface Working_with_matrices : NSObject
-(int)invert_matrix:(int) N andWithMatrix:(double*) matrix;
@end
Run Code Online (Sandbox Code Playgroud)
实施文件
#import "Working_with_matrices.h"
#include <Accelerate/Accelerate.h>
@implementation Working_with_matrices
-(int) matrix_invert:(int) N andWithMatrix:(double*)matrix
{
int error=0;
int *pivot = malloc(N*N*sizeof(int));
double *workspace = malloc(N*sizeof(double));
dgetrf_(&N, &N, matrix, &N, pivot, &error);
if (error != 0) {
NSLog(@"Error 1");
return error;
}
dgetri_(&N, matrix, &N, pivot, workspace, &N, &error);
if (error != 0) {
NSLog(@"Error 2");
return error;
}
free(pivot);
free(workspace);
return error;
} …Run Code Online (Sandbox Code Playgroud) 我hugo_0.11_linux_amd64.tar.gz已从发布页面下载并解压缩该文件,但我无法弄清楚如何运行二进制文件.我花了几个刺在使用go run和sh,但没有运气.任何人都可以提供更多细节吗?
我写了一个Nim程序,
echo("Hello.")
Run Code Online (Sandbox Code Playgroud)
然后我试着为Linux机器交叉编译,
nim c --cpu:i386 --os:linux -c hello.nim
Run Code Online (Sandbox Code Playgroud)
这产生了以下输出:
config/nim.cfg(45, 2) Hint: added path: '/Users/connor/.babel/pkgs/' [Path]
config/nim.cfg(46, 2) Hint: added path: '/Users/connor/.nimble/pkgs/' [Path]
Hint: used config file '/usr/local/lib/nim-0.10.2/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: hello [Processing]
Hint: operation successful (8753 lines compiled; 0.140 sec total; 14.148MB)[SuccessX]
Run Code Online (Sandbox Code Playgroud)
此时我更改了nimcache/目录并尝试执行:
gcc hello.c -o hello.o
Run Code Online (Sandbox Code Playgroud)
但这给了我一个错误:
hello.c:5:10: fatal error: 'nimbase.h' file not found
#include "nimbase.h"
^
1 error generated.
Run Code Online (Sandbox Code Playgroud)
我想,"没什么大不了的,我只会找到nimbase.h并放在nimcache那里的目录中",但在那之后我得到了一个新的错误,
In file included from hello.c:5:
./nimbase.h:385:28: error: 'assert_numbits' …Run Code Online (Sandbox Code Playgroud) 我正在使用Flask作为Web框架,我正在尝试实现Mike Dewar的D3入门一书中的第一个示例.我有一个名为Python脚本run.py和两个目录,templates/并static/包含index.html和service_status.json分别.不幸的是,我的代码根本没有渲染数据,也没有产生任何明显的错误.
这就是我所拥有的run.py:
#!/usr/bin/env python
from flask import Flask, render_template, url_for
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
if __name__=="__main__":
port = 5000
app.debug = True
app.run( port=port )
Run Code Online (Sandbox Code Playgroud)
这就是我所拥有的templates/index.html:
<!DOCTYPE HTML>
<HTML>
<HEAD>
<META CHARSET="utf-8">
<SCRIPT SRC="http://d3js.org/d3.v3.min.js"></SCRIPT>
<SCRIPT>
function draw(data) {
"use strict";
d3.select("body")
.append("ul")
.selectAll("li")
.data(data)
.enter()
.append("li")
.text( function(d){
return d.name + ": " + d.status;
}
);
}
</SCRIPT> …Run Code Online (Sandbox Code Playgroud) 我在GitHub上找到了这个项目; 这是"nimrod矩阵"唯一返回的搜索词.我拿了它的骨头并稍微更改它以便编译没有错误,然后我添加最后两行来构建一个简单的矩阵,然后输出一个值,但"getter"函数不起作用由于某些原因.我修改了添加此处的属性的说明,但有些事情是不对的.
到目前为止,这是我的代码.我想在Nimrod中使用GNU Scientific Library,我认为这是第一个合乎逻辑的步骤.
type
TMatrix*[T] = object
transposed: bool
dataRows: int
dataCols: int
data: seq[T]
proc index[T](x: TMatrix[T], r,c: int): int {.inline.} =
if r<0 or r>(x.rows()-1):
raise newException(EInvalidIndex, "matrix index out of range")
if c<0 or c>(x.cols()-1):
raise newException(EInvalidIndex, "matrix index out of range")
result = if x.transposed: c*x.dataCols+r else: r*x.dataCols+c
proc rows*[T](x: TMatrix[T]): int {.inline.} =
## Returns the number of rows in the matrix `x`.
result = if x.transposed: x.dataCols else: …Run Code Online (Sandbox Code Playgroud) 我在PolynomialFeatures的帮助下拟合了一个模型,但我不知道如何获取模型的系数.代码如下:
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import make_pipeline
import matplotlib.pyplot as plt
X = np.matrix([0,1,2,3,4,5,6,7,8,9,10]).reshape((11,1))
Y = np.matrix([0,2.2,3.5,14.3,20.4,32.1,40.3,
59.1,86.2,90.3,99.9]).reshape((11,1))
a = PolynomialFeatures(15)
modelo = make_pipeline(a, LinearRegression())
modelo.fit(X, Y)
plt.plot(X,Y,'.')
plt.plot(X, modelo.predict(X),'-')
plt.show()
Run Code Online (Sandbox Code Playgroud)
matrix ×2
nim-lang ×2
python ×2
c ×1
compilation ×1
d3.js ×1
flask ×1
frameworks ×1
go ×1
hugo ×1
ios ×1
json ×1
math ×1
nimrod ×1
scikit-learn ×1