Program ReadCSBinary
integer :: len_t, NE
real(8) :: torque, fx
open(101, file='Lowson.ini_0',form='unformatted', ACCESS="STREAM")
read(101) len_t
print *, len_t
read(101) NE
print *, NE
read(101) torque
print *, torque
read(101) fx
print *, fx
close(101)
End
이광세 (Lee, Gwang-Se)
School of Mechanical Engineering, Pusan National University
(Wind Turbine Noise & Broadband Airfoil-Self Noise)
lee.gse@gmail.com / gs.lee@pusan.ac.kr / twitter.com/leegse
Title20110603
이 블로그 검색
2014년 7월 16일 수요일
2014년 7월 2일 수요일
FFT code and application using Matlab and C#
DFT CS : DFT using C# code
FFT, CS, huge zeropadding : FFT using C# code with huge zeropadding
FFT Matlab : FFT using Matlab
FFT, Matlab, zeropadding : FFT using C# code with huge zeropadding
In order to compute fine spectrum using FFT, obtain samples of number of 2^N for predictions and measurements.
If it is difficult to get 2^N samples, try FFT with huge zeropadding.
After using FFT with zeropadding, compensate its spectral resolution and magnitude.
#All code & results uploaded in gslee.code@gmail.com with title as following
'https://sites.google.com/a/leegs.net/projects/BS/02-code_module/fft'
2011년 5월 23일 월요일
bechmark prob. c++/c#/fortran (intel) for computing PI
optimized, windows 2003, vs 2008, Intel(R) Core (TM)2 Quad
1. C++
1. C++
// pi_CPP.cpp : 기본프로젝트파일입니다. #include "stdafx.h" #include "math.h" #include "time.h" using namespace System; int main(array<System::String ^> ^args) { const long num_step= 500000000; long i; double sum, step, pi, x; time_t st, et; step = (1.0/(double)num_step); sum=0.0; Console::WriteLine("================================================="); Console::WriteLine("C++"); Console::WriteLine("-------------------------------------------------"); time(&st); for(i=1; i<=num_step; i++){ x=((double)i -0.5)* step; sum=sum+ 4.0/(1.0+x*x); } time(&et); pi=step*sum; Console::WriteLine(" sum = {0:0.000000000000000}", sum); Console::WriteLine(" PI = {0:0.000000000000000}, (Error = {1:e})", pi, Math::Abs(Math::Acos(-1.0)) - Convert::ToDouble(pi)); Console::WriteLine(" Elapsed Time = {0:0.000} [sec]" , difftime(et,st)); Console::WriteLine("================================================="); return 0; } |
=================================================
C++
-------------------------------------------------
sum = 1570796326.794910000000000
PI = 3.141592653589810, (Error = -2.087219e-014)
Elapsed Time = 7.000 [sec]
=================================================
계속하려면 아무 키나 누르십시오 . . .
2. Fortran
PROGRAM MAIN IMPLICIT NONE INTEGER*8 , PARAMETER :: NUM_STEP = 500000000 INTEGER*8 :: I REAL(KIND=8) :: SUM, STEP, PI, X REAL(KIND=8) :: STIME, ETIME, RTC STEP = (1.0D0/DBLE(NUM_STEP)) SUM=0.0D0 WRITE(*,400) WRITE(*,500) WRITE(*,600) STIME=RTC() !STARTING TIME DO I=1, NUM_STEP X = ( DBLE(I) - 0.5D0) * STEP SUM = SUM + 4.D0/(1.D0+X*X) ENDDO ETIME=RTC() !ENDING TIME PI=STEP*SUM WRITE(*,100) PI, DABS(DACOS(-1.0D0)-PI) WRITE(*,300) ETIME-STIME WRITE(*,400) 100FORMAT(' PI = ', F17.15, ' (ERROR = ', E11.5,')') 300FORMAT(' ELAPSED TIME = ', F8.3, ' [SEC] ' ) 400FORMAT('=================================================' ) 500FORMAT('FORTRAN' ) 600FORMAT('-------------------------------------------------' ) STOP ENDPROGRAM |
=================================================
FORTRAN
-------------------------------------------------
PI = 3.141592653589814 (ERROR = 0.20872E-13)
ELAPSED TIME = 7.000 [SEC]
=================================================
계속하려면 아무 키나 누르십시오 . . .
3. C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace pi_CS { class pi{ static void Main(string[] args) { Pi(); } static void Pi() { long num_step = 500000000; long i; double sum, step, pi, x; DateTime dt = new DateTime(); DateTime dt2 = new DateTime(); step = (1.0 / Convert.ToDouble(num_step)); sum = 0.0; Console.WriteLine("================================================="); Console.WriteLine("C#"); Console.WriteLine("-------------------------------------------------"); dt = DateTime.Now; for (i = 1; i <= num_step; i++) { x = (Convert.ToDouble(i) - 0.5) * step; sum = sum + 4.0 / (1.0 + x * x); } dt2 = DateTime.Now; pi = step * sum; Console.WriteLine(" PI = {0}, (Error = {1:e})", pi, Math.Abs(Math.Acos(-1.0)) - Convert.ToDouble(pi)); Console.WriteLine(" Elapsed Time = {0} [sec]" , dt2.Subtract(dt).TotalSeconds.ToString("#.###")); Console.WriteLine("================================================="); } } } |
=================================================
C#
-------------------------------------------------
PI = 3.14159265358981, (Error = -2.087219e-014)
Elapsed Time = 12.563 [sec]
=================================================
계속하려면 아무 키나 누르십시오 . . .
2011년 5월 16일 월요일
2011년 3월 11일 금요일
C# 형식지정자 (결과 자리수 배치에 유용)
공학문제 해석 후 생성되는 출력 파일 내부의 결과들의 자릿수 배치에 유용함
int a = 1;
Console.WriteLine(a.ToString("x5"));
//result
//00001
int a = 1;
Console.WriteLine(a.ToString("0000"));
//result
//0001
float a = 1.51321548f;
Console.WriteLine(a.ToString("0000.00"));
//result
//0001.51
2010년 12월 30일 목요일
[Codeproject] zedgraph
zedgraph는 C# 코드 기반의 그래프 작성 모듈이다.
다음 웹사이트에서 확인하고 사용하면 쉽게 그래프를 그릴수 있을것이다.
http://www.codeproject.com/KB/graphics/zedgraph.aspx
http://zedgraph.org/wiki/index.php?title=Sample_Graphs
다음 웹사이트에서 확인하고 사용하면 쉽게 그래프를 그릴수 있을것이다.
http://www.codeproject.com/KB/graphics/zedgraph.aspx
http://zedgraph.org/wiki/index.php?title=Sample_Graphs
피드 구독하기:
글 (Atom)


