小编use*_*368的帖子

Ghostscript不可写

尝试在新Macbook上安装八度音,但使用Homebrew时遇到问题.我在这里遵循指示:http: //wiki.octave.org/Octave_for_MacOS_X

我遇到了错误:

Linking /usr/local/Cellar/ghostscript/9.14...
Error: Could not symlink share/ghostscript/Resource
/usr/local/share/ghostscript is not writable.
Run Code Online (Sandbox Code Playgroud)

进入后:

sudo chown -R username:admin /usr/local/bin
brew link ghostscript
Run Code Online (Sandbox Code Playgroud)

我仍然得到同样的错误.如何使ghostscript可写?

macos homebrew octave ghostscript

7
推荐指数
2
解决办法
2931
查看次数

雅可比迭代并未结束

我正在尝试在MATLAB中实现Jacobi迭代,但我无法使其收敛.我已经在网上和其他地方查找了用于比较的工作代码但是我找不到任何与我的代码类似的东西并且仍然有效.这是我有的:

function x = Jacobi(A,b,tol,maxiter)

n = size(A,1);
xp = zeros(n,1); 
x = zeros(n,1); 
k=0; % number of steps

while(k<=maxiter)
    k=k+1;

    for i=1:n
       xp(i) = 1/A(i,i)*(b(i) - A(i,1:i-1)*x(1:i-1) - A(i,i+1:n)*x(i+1:n));
    end

    err = norm(A*xp-b);

    if(err<tol)
        x=xp;
        break;
    end

    x=xp;

end
Run Code Online (Sandbox Code Playgroud)

无论我使用什么A和b,这都会爆炸.这可能是我忽略的一个小错误,但如果有人能解释什么是错的,我将非常感激,因为这应该是正确的,但在实践中并非如此.

matlab numerical numerical-analysis numerical-methods

3
推荐指数
1
解决办法
4597
查看次数

例如,温度转换

我正在玩K&R中的一些代码只是为了好玩但是遇到了一个我无法解释的错误.我正在修改第1.2节中的代码,即温度转换程序:

#include <stdio.h>
/* converts a range of fahrenheit temperatures to celsius
and displays them in a table*/

int main(int argc, char *argv[]){
  float fahr, celsius;
  float lower, upper, step;

  if(argc != 4){
    printf("Usage: ./tempConvert lower upper step\n");
    return 1;
  }

  // note: atof is bad?
  lower = atof(argv[1]);   // lower limit of temperature
  upper = atof(argv[2]);   // upper limit of temperature
  step  = atof(argv[3]);   // step size

  //printf("%f %f %f",lower, upper, step);

  fahr = lower;
  printf("F \t C \n"); …
Run Code Online (Sandbox Code Playgroud)

c floating-point integer kernighan-and-ritchie

0
推荐指数
1
解决办法
155
查看次数