斯卡拉的雅各比安

时间:2017-04-22 12:18:55

标签: r scala matrix calculus scala-breeze

是否有一种方法/库可以计算Scala中的雅可比行列式,类似于R中numDeriv包内的雅可比函数?我正在使用Breeze,但我无法找到任何与Jacobian相关的内容。

为了清楚起见,我想在Scala中执行以下操作:

install.packages("numDeriv")     
library(numDeriv)
logistG <- function(r, p, k, t){
        k * p * exp(r*t) / (k + p * (exp(r*t) - 1))
    }

 a <- function(x, k, deltaT){
 c(r=x[1],logistG(r=x[1], p=x[2], k, deltaT))
      }

k <- 100
p0 <- 0.1*k
r <- 0.2
deltaT <- 0.1
x <- c(r, p0)
A <- jacobian(a, x=x, k=k, deltaT=deltaT)  

1 个答案:

答案 0 :(得分:0)

也许你可以将我写过的以下Java代码转换为Scala:

<!DOCTYPE html>
<html lang="da">
    <head>
        <meta charset="utf-8">
    </head>
    <body>
        <script src="//code.jquery.com/jquery-3.2.1.min.js" integrity="sha384-xBuQ/xzmlsLoJpyjoggmTEz8OWUFM0/RC5BsqQBDX2v5cMvDHcMakNTNrHIW2I5f" crossorigin="anonymous"></script>
        <script src="//code.jquery.com/ui/1.12.0/jquery-ui.min.js" integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E=" crossorigin="anonymous"></script>
        <script src="/upload/js/blueimp/jquery.fileupload.min.js"></script>
        <form id="upload_form" enctype="multipart/form-data" method="post" action="/upload/">
            <input id="upload_input" type="file" name="files[]">
            <input type="hidden" name="send" value="1">
        </form>
        <div id="upload_console"></div>
        <script>
            'use strict';

            $(function(){
                var div = $('#upload_console')
                $('#upload_form').fileupload({
                    fileInput : $('#upload_input'),
                    progress : function(e, data){
                        //console.log(data.loaded);
                        //console.log(parseInt(data.loaded / data.total * 100, 10));
                        div.append('<div>'+data.loaded+'</div>')
                    },
                    complete : function(e, data){
                        //console.log('done');
                        div.append('<div>done!</div>')
                    }
                });
            });
        </script>
    </body>
</html>