배열

배열의 선언

1
int grad[10]; // 자료형, 배열 이름, 배열 크기

배열의 초기화

1
int grade[5] = {10, 20, 30, 40, 50};
  • 만약 배열의 크기가 초기값의 개수보다 크다면 나머지는 0으로 초기화 된다.
  • 배열의 크기를 선언하지 않으면 초기값의 개수에 맞춰서 선언된다.

배열의 복사

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <windows.h>
using namespace std;

int main() {
const int SIZE = 5;
int i;
int a[SIZE] = { 1, 2, 3, 4, 5 };
int b[SIZE];

for (i = 0; i < SIZE; i++)
b[i] = a[i];
for (i = 0; i < SIZE; i++)
cout << "b[" << i << "] = " << b[i] << endl;
system("pause");
}
Read more »

자료형

  • short - short형 정수
  • int - 정수
  • long - long형 정수
  • unsigned short - 부호없는 short형 정수
  • unsigned int - 부호없는 정수
  • unsigned long - 부호없는 long형 정수
  • char - 문자 및 정수
  • unsigned char - 문자 및 부호없는 정수
  • float - 단일정밀도 부동소수점
  • double - 두배정밀도 부동소수점
  • bool - True or False
Read more »

Runge-Kutta Method for ODE

Process

  • Heun’s Method(a(2)=1/2)
  • Ralston’s Method(a(2)=2/3)
  • y(i+1)=y(i)+(a(1)k(1)+a(2)k(2))h
  • k(1)=f(x(i), y(i))
  • k(2)=f(x(i)+p(1)h, y(i)+q(11)k(1)h)
Read more »

Least squares regression for a straight line

Process

  • Residual의 합 Sr을 구하여 미분
  • 각각의 Parameter에 대한 편미분 값이 0이 되도록 계산
  • 구한 a(0)와 a(1)의 값으로 식 구하기
  • The standard error of the estimate - S(y/x)
  • The correlation coefficient - r
  • (5, 5)라는 Data point가 주어질때, 유효한가?
Read more »