[Java] 현재 경로 출력

코딩/Java 2015. 3. 24. 15:12
System.out.println(System.getProperty("user.dir");

[Linux] .vimrc 설정

Tips/Linux 2014. 12. 1. 15:51

꼭 Linux에서만 적용되는 건 아니고, gvim도 동일.

set ts=4
set sw=4
set sts=4
set expandtab
set smartindent
set cindent
set laststatus=2

 

set ts=4

--> tab 크기가 4 spaces와 동일

set sw=4

--> auto-indent될 때 tab 크기가 4 spaces

set sts=4

--> editing 시에 tab 크기가 4 spaces

set expandtab

--> tab을 spaces로 치환

set smartindent

--> new line 시작 시 smart indenting 적용

set cindent

--> C program style indent 지원

set laststatus=2

--> 맨 아래 상태 표시줄 크기 지정

 

참조: http://vimdoc.sourceforge.net/htmldoc/options.html

'Tips > Linux' 카테고리의 다른 글

[LINUX] 쉘 프롬프트에 IP 보이기  (0) 2015.11.09
[Linux] 주기적으로 명령어 실행  (0) 2015.05.18
[Linux] standard error 파일 저장 및 화면 출력을 한번에  (0) 2015.05.18
vim 명령어  (0) 2013.12.12
Linux 컴파일 과정  (0) 2013.10.29

[CUDA] NVCC -gencode

코딩/CUDA 2014. 10. 8. 10:14

nvcc 사용시 -gencode 옵션은 -arch 옵션과 -code 옵셥을 합친 것이다.

 

-arch 옵션: '-arch=compute_20'과 같이 사용

생성될 PTX 코드의 버전을 지정        -> 'compute_XX'는 virtual architecture를 의미함

PTX 코드는 GPU 드라이버에서 JIT (Just-In-Time) 컴파일을 통해 실행이 가능함

(SDK가 필요 없다는 장점이 있음)

-code 옵션: '-code=sm_20'과 같이 사용

생성될 binary 코드(SASS)의 버전을 지정     -> 'sm_XX'는 real architecture를 의미함

binary 코드는 별도의 JIT 컴파일 과정 없이 지정된 architecture에서 곧바로 실행이 가능

(컴파일 시간이 짧다는 이점이 있음) 

-gencode 옵션: '-gencode arch=compute_20,code=sm_20'과 같이 사용

 

그렇다면 다음과 같이 한번에 여러 -gencode 옵션을 줄 때의 이점이 무엇인가.....하면....

-gencode arch=compute_20,code=sm_20
-gencode arch=compute_20,code=sm_21
-gencode arch=compute_21,code=sm_21

 

여러 버전의 PTX, binary 코드를 미리 생성해두어 상위 아키텍쳐에 대한 '호환성'을 높일 수 있다는 것임.

대신 옵션 수에 비례하여 실행 코드의 크기가 커진다는 단점도 있음.

 

(참고: http://stackoverflow.com/questions/17599189/what-is-the-purpose-of-using-multiple-arch-flags-in-nvidias-nvcc-compiler)

[Math] What is a manifold?

수학 2014. 8. 21. 09:44

<Manifold란?>

Wikipedia 정의에 따르면,

In mathematics, a manifold is a topological space that resembles Euclidean space near each point. More precisely, each point of an n-dimensional manifold has a neighbourhood that is homeomorphic to the Euclidean space of dimension n. ... 

(출처: http://en.wikipedia.org/wiki/Manifold)

...라고 한다.-0-

 

나같은 비수학전공자에게는 전혀 와닿지 않은 문장이라서 '한방에' 이해하기 쉬운 설명을 찾던 중

다음과 같은 글을 발견! 

shortest description i've heard that i thought helped was that a manifold surface is one in which every edge is adjacent to two faces. i believe that property is necessary and sufficient.

e.g. a triangle is not a manifold surface - each edge is adjacent to a single face. a cube is a manifold surface. if you take one face away from the cube, it is no longer manifold.

some properties that come out of this - no open boundaries (like the cube missing a face), the surface is "air-tight", it has a distinct inside and outside surface, etc.

non-manifold is any surface that doesn't meet the requirement for a manifold surface.

(출처: https://www.opengl.org/discussion_boards/showthread.php/164373-what-is-manifold-and-non-manifold-surface)

 

딱 와닿지 않은가?? :D

쉽게 그림으로 보면 아래와 같은 것들이 manifold라고 할 수 있겠다.

(출처: http://mathworld.wolfram.com)

 

 

<Manifold의 차원?>

Manifold의 차원이란 manifold 상의 local area에 대응하는 Euclidean space의 차원에 대응한다.

예를 들면, 2차원 원의 경우 1차원 manifold라고 할 수 있는데, 원을 여러 부분으로 잘게 자르면 각 부분은 1차원 직선에 대응하기 때문이다.

비슷하게 3차원 구의 경우는, 구를 잘게 자른 각 patch는 2차원 평면에 대응하므로 2차원 manifold라고 할 수 있다.

[Python] Matplotlib을 이용한 histogram 그리기

코딩/Python 2014. 8. 4. 11:07

[Matplotlib 설치]

1. Numpy 설치

- 설치된 Python 버전에 맞는 numpy 설치

2. Matplotlib 설치

- 구글링해서 1.3.1 버전을 받아서 설치했더니 'matplotlib requires dateutil'이라는 에러 발생

- 그냥 아래 링크 설명대로 github에서 다시 받아서 설치했더니 문제 없었음
(http://matplotlib.org/users/installing.html)

 

[Histogram 그리기]

1. 예제 코드

- TP_list와 FP_list에 들어있는 값들에 대한 histogram을 겹쳐서 그림

- 'alpha=0.5'를 통해 투명도 조절

import matplotlib.pyplot as plt
...
plt.hist(TP_list, bins=100, color='b', label='TP')
plt.hist(FP_list, bins=100, color='r', alpha=0.5, label='FP')
plt.title('Score Histogram')
plt.xlabel('Scores')
plt.ylabel('Frequency')
plt.legend()
plt.show()

 

2. 그 외

- 자세한 설명은 생략한다 아래 링크 참조

(http://bespokeblog.wordpress.com/2011/07/11/basic-data-plotting-with-matplotlib-part-3-histograms/)

 

'코딩 > Python' 카테고리의 다른 글

[Python] 파일 라인 수정  (0) 2014.04.28

[CUDA] Visual Studio 2010에서 C++ 프로젝트를 CUDA 프로젝트로 변환

코딩/CUDA 2014. 7. 31. 10:50

참조: http://stackoverflow.com/questions/3778799/how-do-i-start-a-cuda-app-in-visual-studio-2010

(여기서 Tom의 답글 참조)

 

0. CUDA SDK 설치

  - Visual Studio에 CUDA 코드 컴파일을 위한 '빌드 사용자 지정 파일'이 자동으로 추가됨

 

1. 솔루션 탐색기에서 기존 C++ 프로젝트 선택 후 우클릭 -> "사용자 지정 빌드" 선택

 

2. CUDA X.X 체크 후 확인

 

3. 다시, 솔루션 탐색기에서 기존 C++ 프로젝트 선택 후 우클릭 -> 속성 -> 링커 -> 입력 선택

 

4. 추가 종속성에 'cudart.lib' 추가

 

(선택: 기존 .cpp 파일을 NVCC로 컴파일하는 방법)

5. 솔루션 탐색기에서 기존 .cpp 파일을 선택 후 우클릭 -> 구성 속성 -> 일반에서 항목 형식을 'CUDA C/C++'로 변환

  - 파일명도 .cu로 변환하는 것이 좋음

 

 

+ 추가: CUDA와 다른 외부라이브러리 (ex: OpenCV, STL 등) 같이 사용 시 주의점

(참조: http://stackoverflow.com/questions/1847599/why-wont-opencv-compile-in-nvcc)

- NVCC가 STL, OpenCV 등 기타 라이브러리 코드를 제대로 인식하지 못하는 문제가 있음

- kernel 정의하는 파일은 .cu로 분류해서 NVCC를 통해 별도로 컴파일

- 기타 외부라이브러리 기능을 사용하는 코드는 따로 .cpp 파일에 작성 후 C++ 컴파일러로 컴파일 후 사용

 

'코딩 > CUDA' 카테고리의 다른 글

[CUDA] NVCC -gencode  (0) 2014.10.08

SyntaxHighlighter - 코드를 보기 좋게 올리자!

블로깅 2014. 7. 26. 14:21

블로그에 코드를 깔끔하게 올리는 방법을 찾다가 발견!

http://alexgorbatchev.com/SyntaxHighlighter/

 

최신 버전을 다운로드 받은 후, 블로그 HTML/CSS 편집을 해주면 끝.
(자세한 사항은 홈페이지, 구글링, 혹은 http://cocosoft.kr/68 여길 참조)

 

글을 쓸 때는 다음과 같이 해주면 된다.

 

<pre class="brush:brush Name">


소스 코드 입력


</pre>

 

Brush name은 아래를 참조해서 적어주면 됨.

 

Brush name Brush aliases File name
ActionScript3 as3, actionscript3 shBrushAS3.js
Bash/shell bash, shell shBrushBash.js
ColdFusion cf, coldfusion shBrushColdFusion.js
C# c-sharp, csharp shBrushCSharp.js
C++ cpp, c shBrushCpp.js
CSS css shBrushCss.js
Delphi delphi, pas, pascal shBrushDelphi.js
Diff diff, patch shBrushDiff.js
Erlang erl, erlang shBrushErlang.js
Groovy groovy shBrushGroovy.js
JavaScript js, jscript, javascript shBrushJScript.js
Java java shBrushJava.js
JavaFX jfx, javafx shBrushJavaFX.js
Perl perl, pl shBrushPerl.js
PHP php shBrushPhp.js
Plain Text plain, text shBrushPlain.js
PowerShell ps, powershell shBrushPowerShell.js
Python py, python shBrushPython.js
Ruby rails, ror, ruby shBrushRuby.js
Scala scala shBrushScala.js
SQL sql shBrushSql.js
Visual Basic vb, vbnet shBrushVb.js
XML xml, xhtml, xslt, html, xhtml shBrushXml.js

 

 

덧, SyntaxHighligher 사용시 <..>에 자동 태그가 되는 것 방지 방법

(예: #include <stdio.h>에서 <stdio.h>를 태그로 인식해서 뒤에 자동으로 </stdio.h>가 붙음)
-> #include &lt;stdio.h> 이렇게 '<'대신 '&lt;'사용!

MS Office 수식편집기 단축키

Tips/MS Office 2014. 5. 16. 08:06

 

 

'Tips > MS Office' 카테고리의 다른 글

파워포인트 삽입 기호  (0) 2014.04.03

[Python] 파일 라인 수정

코딩/Python 2014. 4. 28. 09:39

예제> 'test.txt'에서 'old_term: ... '으로 시작하는 라인을 'new_term: ...'으로 수정


 

with open('test.txt', 'r+') as f:              # file을 열고 알아서 닫아 줌
    lines = []
    new_line = 'new_term: this is test\n'
    for line in f:
        if(line.startswith('old_term:')):      # 'old_term:'으로 시작하는 line을 찾음
            lines = lines + [new_line]
        else:
            lines = lines + [line]
f.seek(0)                                      # file pointer 위치를 처음으로 돌림
f.writelines(lines)                            # 수정한 lines를 파일에 다시 씀
f.truncate()                                   # 현재 file pointer 위치까지만 남기고 나머지는 정리 

'코딩 > Python' 카테고리의 다른 글

[Python] Matplotlib을 이용한 histogram 그리기  (0) 2014.08.04

윈도우에서 batch 파일 실행

Tips/Windows 2014. 4. 28. 08:59

<윈도우 command line 명령어>

- start: 지정한 프로그램이나 명령을 별도의 창을 띄워 시작 실행
(start /B: 새 창을 만들지 않고 응용 프로그램 시작)

- timeout /T 50: 50 secs 동안 대기 후 다음 라인 실행

<윈도우 batch 파일 실행>

 - 예1) test.py의 인자를 다르게 하여 60초 간격으로 실행

python test.py 1
timeout /t 60
python test.py 2
timeout /t 60
python test.py 3

- 예2) test.exe의 인자를 다르게 하여 60초 간격으로 실행
(start 명령을 쓰지 않으면 실행이 안될 수 있음)

start test.exe 1
timeout /t 60
start test.exe 2
timeout /t 60
start test.exe 3