Last active
October 14, 2016 05:07
-
-
Save tanaikech/a9171857cea11167cd6354e66ace58ce to your computer and use it in GitHub Desktop.
Google Apps Scriptで配列要素の総和処理を高速で行いたい ref: http://qiita.com/tanaike/items/17c88c69a0aa0b8b18d7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Declare a string variable arr, sum | |
Declare an integer variable loopcounter | |
Set arr to size n | |
for loopcounter = 0 to (size of arr) - 1 | |
sum = sum + arr[loopcounter] | |
loopcounter = loopcounter + 1 | |
endfor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\Psi = \sum_{\lambda=1}^{\theta} \mu \lambda \tag{1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\frac{d\Psi(\phi, \omega)}{d\omega} = -\frac{\theta \log \phi}{\phi^{\omega}} + \phi + 3 \tag{6} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\omega = \log_{\phi}{\frac{\theta \log \phi}{\phi + 3}} \tag{7} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\omega = \log_{\phi}\theta-1 \tag{8} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOUWA.souwa(配列, デリミタ, 改行コード); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Declare a string variable arr, tempsum, sum | |
Declare an integer variable division, loopcounter1, loopcounter2 | |
Set arr to size n | |
division = d | |
for loopcounter1 = division to (size of arr) - 1 | |
for loopcounter2 = 0 to (size of arr) - 1 | |
tempsum = tempsum + arr[loopcounter2] | |
loopcounter2 = loopcounter2 + 1 | |
endfor | |
sum = sum + tempsum | |
tempsum = '' | |
loopcounter2 = loopcounter1 | |
loopcounter1 = loopcounter1 + division | |
endfor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\left(\sum_{\lambda=1}^{\phi_1} \mu_{1} \lambda\right)\frac{\theta_{1}}{\phi_{1}} + | |
\left(\sum_{\lambda=1}^{\phi_2} \mu_{2} \lambda\right)\frac{\theta_{2}}{\phi_{2}} + | |
\cdots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\cdots + | |
\left(\sum_{\lambda=1}^{\phi_{\omega-1}} \mu_{\omega-1} \lambda\right)\frac{\theta_{\omega-1}}{\phi_{\omega-1}} + | |
\left\{\left(\sum_{\lambda=1}^{\phi_{\omega}} \mu_{\omega} \lambda\right)\frac{\theta_{\omega}}{\phi_{\omega}} + \sum_{\lambda=1}^{\frac{\theta_{\omega}}{\phi_{\omega}}} \mu_{\omega}\phi_{\omega}\lambda \right\} | |
\tag{2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\theta_{\omega} = \frac{\theta}{\phi^{\omega-1}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\mu_{\omega} = \mu\phi^{\omega-1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\Psi(\phi, \omega) = \frac{\mu\theta}{2}\left\{ \left(\phi + 3\right)\omega + \frac{\theta}{\phi^{\omega}} - 1 \right\} \tag{3} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\frac{d\Psi(\phi, \omega)}{d\phi} = \frac{\mu\theta\omega}{2}\left( 1 - \theta \phi^{-(\omega+1)} \right) \tag{4} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\phi = \left( \frac{1}{\theta} \right)^{-\frac{1}{\omega+1}} \tag{5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ss2csv() { | |
var ss_file = "sampless"; // csvに変換したいスプレッドシートのファイル名 | |
var csv_file = "sampless.csv"; // 出力するcsvファイル名 | |
var sheet = SpreadsheetApp.open(DriveApp.getFilesByName(ss_file).next()); | |
var data = sheet.getRange('a1').offset(0, 0, sheet.getLastRow(), sheet.getLastColumn()).getValues(); | |
var csvdata = SOUWA.souwa(data, ',', '\r\n'); | |
DriveApp.createFile(csv_file, csvdata, MimeType.CSV); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment