3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

計算物理学 Rubin H. Landau 参考文献・docker登録
https://qiita.com/kaizen_nagoya/items/af924f5ac71ff5cc8c89

docker/ubuntu
# cd /home/cp/HCPcodes
# clang pond.c -o pond
pond.c:19:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main()  {
^
1 warning generated.
# ./pond
data stored in pond.dat
# cat pond.dat
1	4.000000
2	4.000000
...
998	3.130261
999	3.131131
1000	3.132000
# gcc pond.c
pond.c:19:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 main()  {
 ^~~~

main関数の前にint をつければよい。

vond.c
/* From "COMPUTATIONAL PHYSICS", 3rd Ed, Enlarged Python eTextBook  
    by RH Landau, MJ Paez, and CC Bordeianu
    Copyright Wiley-VCH Verlag GmbH & Co. KGaA, Berlin;  Copyright R Landau,
    Oregon State Unv, MJ Paez, Univ Antioquia, C Bordeianu, Univ Bucharest, 2015.
    Support by National Science Foundation
*/
//https://physics.oregonstate.edu/~landaur/Books/CPbook/Codes/HPCodes/pond.c
// pond.c: *Monte-Carlo integration to determine pi (stone throwing 

#include <stdio.h>
#include <stdlib.h>

// if you don't have drand48 uncomment the following two lines 
//    #define drand48 1.0/RAND_MAX*rand 
//    #define srand48 srand              

#define max 1000                     // number of stones to be thrown
#define seed 68111                       // seed for number generator

int main()  {
	
  int i, pi = 0;
  double x, y, area;
  FILE *output;                              // save data in pond.dat
  output = fopen("pond.dat","w");
  srand48(seed);                         // seed the number generator
  for (i = 1; i<= max; i++) {
    x = drand48()*2-1;                      // creates floats between
    y = drand48()*2-1;                                    // 1 and -1
    if ((x*x + y*y)<1) pi++;                    // stone hit the pond
    area = 4*(double)pi/i;                          // calculate area
    fprintf(output, "%i\t%f\n", i, area);
  }
  printf("data stored in pond.dat\n");
  fclose(output);
  return i;
}

Reference

無線網(Wi-Fi)空中線(antenna)(0) 記事一覧(118/300目標)
https://qiita.com/kaizen_nagoya/items/5e5464ac2b24bd4cd001

Ethernet 記事一覧 Ethernet(0)
https://qiita.com/kaizen_nagoya/items/88d35e99f74aefc98794

Wireshark 一覧 wireshark(0)、Ethernet(48) https://qiita.com/kaizen_nagoya/items/fbed841f61875c4731d0

仮説(0)一覧(目標100現在40)
https://qiita.com/kaizen_nagoya/items/f000506fe1837b3590df

安全(0)安全工学シンポジウムに向けて: 21
https://qiita.com/kaizen_nagoya/items/c5d78f3def8195cb2409

Qiita(0)Qiita関連記事一覧(自分)
https://qiita.com/kaizen_nagoya/items/58db5fbf036b28e9dfa6

鉄道(0)鉄道のシステム考察はてっちゃんがてつだってくれる
https://qiita.com/kaizen_nagoya/items/26bda595f341a27901a0

日本語(0)一欄
https://qiita.com/kaizen_nagoya/items/7498dcfa3a9ba7fd1e68

英語(0) 一覧
https://qiita.com/kaizen_nagoya/items/680e3f5cbf9430486c7d

転職(0)一覧
https://qiita.com/kaizen_nagoya/items/f77520d378d33451d6fe

数学関連記事100 
https://qiita.com/kaizen_nagoya/items/d8dadb49a6397e854c6d

物理記事 上位100
https://qiita.com/kaizen_nagoya/items/66e90fe31fbe3facc6ff

自動車 記事 100
https://qiita.com/kaizen_nagoya/items/f7f0b9ab36569ad409c5

言語・文学記事 100
https://qiita.com/kaizen_nagoya/items/42d58d5ef7fb53c407d6

医工連携関連記事 100
https://qiita.com/kaizen_nagoya/items/6ab51c12ba51bc260a82

通信記事100
https://qiita.com/kaizen_nagoya/items/1d67de5e1cd207b05ef7

OSEK OS設計の基礎 OSEK(100)
https://qiita.com/kaizen_nagoya/items/7528a22a14242d2d58a3

一覧:携帯計画者日記(0)
https://qiita.com/kaizen_nagoya/items/005d38c6f55c85570e74

AUTOSAR R22-11 Qiita記事一覧 20230421(1)
https://qiita.com/kaizen_nagoya/items/81a35774f1aa3d64d3f6

ボッシュ自動車handbook(英語)11版(0) 課題と記事一覧
https://qiita.com/kaizen_nagoya/items/dfa35aa6f669e5df983e

R3(0) on "What are the most important statistical ideas of the past 50 years? " Andrew Gelman, Aki Vehtari
https://qiita.com/kaizen_nagoya/items/a8eac9afbf16d2188901

官公庁・学校・公的団体(NPOを含む)システムの課題、官(0)
https://qiita.com/kaizen_nagoya/items/04ee6eaf7ec13d3af4c3

一覧の一覧( The directory of directories of mine.) Qiita(100)
https://qiita.com/kaizen_nagoya/items/7eb0e006543886138f39

プログラマが知っていると良い「公序良俗」
https://qiita.com/kaizen_nagoya/items/9fe7c0dfac2fbd77a945

自動制御、制御工学一覧(0)
https://qiita.com/kaizen_nagoya/items/7767a4e19a6ae1479e6b

Rust(0) 一覧 
https://qiita.com/kaizen_nagoya/items/5e8bb080ba6ca0281927

小川清最終講義、最終講義(再)計画, Ethernet(100) 英語(100) 安全(100)
https://qiita.com/kaizen_nagoya/items/e2df642e3951e35e6a53

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
This article is an individual impression based on the individual's experience. It has nothing to do with the organization or business to which I currently belong.

文書履歴(document history)

ver. 0.01 初稿 20190818
ver. 0.04 URL追記 20230302

最後までおよみいただきありがとうございました。

いいね 💚、フォローをお願いします。

Thank you very much for reading to the last sentence.

Please press the like icon 💚 and follow me for your happy life.

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?