2008年6月10日

Building GSL 1.8 under Windows Step By Step

This article is from the discussion thread at this page


Assuming you use Visual C++ 2005 - Studio Vers. 8.

// 1) Get the sourcecode
- Download the sources:
http://gnuwin32.sourceforge.net/downlinks/gsl-src-zip.php
- decompress

// 2) Configure
- Open the config.h.msvc in the VC8 directory
- change "#define HAVE_DECL_LOG1P 1" entry to "#define HAVE_DECL_LOG1P 0"
(just to be on the safe side: change all #define HAVE_... 1 to 0)

// 3) Make
- open the visual studio solution libgsl.sln in the VC8 directory.
- Build->Batch Build
- Check the configurations you need (DLL/Static/Debug/Release) and build them
(if you don't know what you need, check everything EXCEPT the 4 install_libgsl
entries)

// 4) Install
- Open the Property Page of the install_libgsl project (SolutionExplorer->right
click->Properties)
- Select "All Configurations"
- Go to Configuration Properties -> Build Events -> Pre-Build Event
- Edit the command line (click [...])
- Change the install location in the second line (to your GnuWin32 directory)
(If you installed the gsl win32 binaries with standard paramteres that's
C:\GnuWin32)
- Build the "install_libgsl" project (SolutionExplorer -> right click -> build)

// 4.1) Fix the directory error
If there are no .lib or .dll files in the /lib and /bin directory the copy
source directories are wrong:
- Go to the Pre-Buil Event command line again (see Step 4)
In my version there where whitespaces in all Debug-StaticLib,
Release-StaticLib,
Debug-DLL, Release-DLL entries
If you are finished with step 3) those should be the same as your build output
directories
- Just change everything that looks like this: ../Debug - Static Lib/..
to ../Debug-StaticLib/..
( The same with: Release - Static Lib, Debug - DLL, Release DLL)
- Build the "install_libgsl" project

How do I use GSL on Visual C++ 2005 ?

This article is originally from the site. Here is its copy.

DOWNLOAD AND INSTALL GSL SOFTWARE

1.Download gsl-1.8.exe from http://sourceforge.net/project/showfiles.php?group_id=23617&package_id=19804
(contains binaries and .lib files)
2.Execute and finish the installation.

3.Download gsl-1.8-src.exe from http://sourceforge.net/project/showfiles.php?group_id=23617&package_id=19804
4.Execute and finish the installation.

BUILD GSL LIBRARIES FOR Visual studio
1. Launch Visual C++ Studio
2. Open project C:\Program Files\GnuWin32\src\gsl\1.8\gsl-1.8\VC8\libgsl.sln (assuming default path - replace if it is a different location)
3. Do a build all
4.Verify that after build is complete, new files are generated in subfolders in C:\Program Files\GnuWin32\src\gsl\1.8\gsl-1.8\VC8\libgsl

CONFIGURE PATH SETTINGS IN VISUAL C++ STUDIO
1.Launch Visual C++ studio
2.Select Tools->Options Menu
3.On the tree display in the Options dialog box, select branch for Projects and solutions->VC++ directories
4.On the right side of the dialog, select Executable files in the "show directories for" combo box and add the following paths:
C:\Program Files\GnuWin32\src\gsl\1.8\gsl-1.8\VC8\libgslcblas\Debug-DLL
C:\Program Files\GnuWin32\src\gsl\1.8\gsl-1.8\VC8\libgsl\Debug-DLL

5.In the "show directories for" combo box select "Include files" and add the following path:
C:\Program Files\GnuWin32\include

6.In the "show directories for" combo box select "Library files" and add the following paths:
C:\Program Files\GnuWin32\src\gsl\1.8\gsl-1.8\VC8\libgsl\Debug-DLL
C:\Program Files\GnuWin32\src\gsl\1.8\gsl-1.8\VC8\libgslcblas\Debug-DLL

HOW DO I USE GSL LIBRARY IN MY VC++ PROJECT?
1.Launch Visual studio
2.Open your VC++ project.
3.select menu Project -> properties
4.In the property pages dialog, select tree item "configration properties->Linker->Input
5.On the right hand side details, choose the field "Additional Dependencies" and append the following entries by clicking the ... button:
libgsl_dll_d.lib
libgslcblas_dll_d.lib

2008年6月3日

設定台灣地理坐標的方法

我定義系統坐標的方法如下:
First of all →starting arcCatalog→瀏覽這三張圖層 →在圖層上直接點兩下或是按滑鼠右鍵,選擇properties →在選XY coordinate system→如果此圖層沒有座標系統的話,details:是空白的→由於arcgis並沒有內鍵的台灣的TM2度分帶的投影座標系統格式,所以我必須新增→選擇new→projected→name:TM67(or TM97)→projection’s name:Transverse_Mercator→false_Easting:250000,false_Northing:0,Central_Meridian:121,Scale_Factor:0.9999,Latitude_Of_Origin:0→Linear Unit name:Meter→按一下select→Geographic Coordinate System→Asia→Taiwan1967(或taiwan1997, 若想要兩個都建立的話,重複上述的steps)→套用→確定→完成了新增座標系統之後,不要忘了將你的所新增的座標系統,儲存起來→Save as →存在projected coordinate systems裏→以後要用時就方便了。

如何截取一個圖層的中你想要的部份及如何設定你想要的圖層中的坐標單位。

1、這問題非常的簡單,在你要截取的圖層,按右鍵>>open attribute table>>選擇你的要資料後>>再回圖層,也是按右鍵>>data>>export data 。這樣就有截取你想要的圖層了。
2、view→data frame properities→general。就會看到units。有兩個-map跟display都選。

設定gis的地理投影座標系統。

我定義系統坐標的方法如下:
First of all →starting arcCatalog→瀏覽這三張圖層 →在圖層上直接點兩下或是按滑鼠右鍵,選擇properties →在選XY coordinate system→如果此圖層沒有座標系統的話,details:是空白的→由於arcgis並沒有內鍵的台灣的TM2度分帶的投影座標系統格式,所以我必須新增→選擇new→projected→name:TM67(or TM97)→projection’s name:Transverse_Mercator→false_Easting:250000,false_Northing:0,Central_Meridian:121,Scale_Factor:0.9999,Latitude_Of_Origin:0→Linear Unit name:Meter→按一下select→Geographic Coordinate System→Asia→Taiwan1967(或taiwan1997, 若想要兩個都建立的話,重複上述的steps)→套用→確定→完成了新增座標系統之後,不要忘了將你的所新增的座標系統,儲存起來→Save as →存在projected coordinate systems裏→以後要用時就方便了。

c語言-pointer(4)-雙重指標

在c語言中,指標不但可以指向任何一種資料型態的變數,還可以指向指標,這種指標的指標,我們稱為雙重指標。
格式:
型態**指標變數;
舉一個例子:
int **ptri;
int *(*ptri);
char *(*ptrch);
以上皆是合法的宣告。
雙重指標的概念很簡單如下:
宣告一個:
int i=5,*a,**b;

i的值=5,&i=0253FDD4
a的值=0253FDD4,*a=5,&a=0253FDD0
b的值=0253FDD0,*b=0253FDD4,**b=5,&b=0253FDCC

c語言-pointer(3)-指數與陣列(含字串陣列)

陣列可以看成指標的分身。不同的是,陣列的固定長度的記憶体區塊,而指標是一個變數。
舉一個簡單的例子:
int a[3]={5,7,9};
在指標上(要記):
1、值方面:
*a=5
*(a+1)=7
*(a+2)=9
2、位址方面:
a=&a[1]
a+1=&a[2]
a+2=&a[3]
_____________________
字串陣列:(複習一下,文字之後最後一格是存 \0 )
字串陣列多多少少有浪費空間的情形發生,但若是利用指標陣列來解決,嘿嘿~~那就可以達到用就占,不用就不占的完美境界了。
宣告的方式:
一維指標陣列的宣告格式:
型態*陣列名稱[個數];
舉個例子就是:
char *name[3]={"david","jane wang","tom lee"};
舉一個程式:
/*指標陣列*/
#include
int main(void)
{
int i;
char *name[3]={"david","jane wang","tom lee"};

for(i=0;i<3;i++)
printf("name[%d]=%s\n",i,name[i]);
return 0;
}
_________________________________
二維陣列
舉一個例子,宣告一個int num[3][3],二維陣列可以視為多個一維陣列。
int num[3][3]
1 2 3
4 5 6
7 8 9
可以看成:
num[0]→1 2 3
num[1]→4 5 6
num[2]→7 8 9

num={{1,2,3},{4,5,6},{7,8,9}};

就列而言:
num+0代表第一列第一個的位址。
num+1代表第二列第一個的位址。
num+2代表第三列第一個的位址。

就行而言:
無代表

所以要表達第幾列第幾行時的"位址",為以下三種表達:
num+0 *(num)+1 *(num)+2
num+1 *(num+1)+1 *(num+1)+2
num+2 *(num+2)+1 *(num+2)+2
or
num+0 *(num+0)+1 *(num+0)+2
num+1 *(num+1)+1 *(num+1)+2
num+2 *(num+2)+1 *(num+2)+2
or
*(num+0)+0 *(num+0)+1 *(num+0)+2
*(num+1)+0 *(num+1)+1 *(num+1)+2
*(num+2)+0 *(num+2)+1 *(num+2)+2
值得注意的是num+1+1=num+2

若要表達其"值" 的話則為:
*(*(num+0)+0) *(*(num+0)+1) *(*(num+0)+2)
*(*(num+1)+0) *(*(num+1)+1) *(*(num+1)+2)
*(*(num+2)+0) *(*(num+2)+1) *(*(num+2)+2)

c語言-pointer(2)-指標與函數

在函數的return只能回傳一個值。當需要回傳二個值以上的時候,就需要利用到指標了。
(1)宣告一個將指標當成引數傳入函數的函數產原型之宣告。格式如下:
剛開始:fucn(int*,char*);

函數部份(副程式):
int func(int *ptr1,char *ptr2)
舉一個例子:
/*傳回多個數值的函數*/
#include
#include
void rect(int,int,int*,int*);
int main(void)
{
int a=5,b=8;
int area,length;

rect(a,b,&area,&length);
printf("area=%d,total length=%d\n",area,length);
system("pause");
return 0;
}

void rect(int x,int y,int *ptr1,int *ptr2)
{
*ptr1=x*y;
*ptr2=2*(x+y);
return;
}
____________________________________________________
結果:
area=40,total length=26
____________________________________________________
這一個程式可以更改成

/*傳回多個數值的函數*/
#include
#include
void rect(int,int,int*,int*);
int main(void)
{
int a=5,b=8;
int *area,*length;
area=&a;
length=&b;
rect(a,b,area,length);
printf("area=%d,total length=%d\n",*area,*length);
system("pause");
return 0;
}

void rect(int x,int y,int *ptr1,int *ptr2)
{
*ptr1=x*y;
*ptr2=2*(x+y);
return;
}
_____________________________________________________________
結果:
area=40,total length=26
____________________________________________________________
有注意兩者的差別嗎?
指標的秘密在於位址。了解就都懂了。第一個程式是儲在自己的指標的位址。
而第二個程式則是借用a、b的位址,頓時,a,b的值也改變成a=40,b=26。
____________________________________________________________
介紹一下函數的傳回指標型態的變數值,只要在宣告函數原型及定義函數時,在函數名稱前面加上指標符號*,即可傳回指標了。
剛開始
int *maximum(int *);
.
.
.
ptr=maximum(a); /* 不需要有* */


函數部份(副程式)
int *maximun(int *m)
.
.
.
return max;

c語言-pointer(1)-基本介紹

首先,介給一下%u、%p的用法, 兩者適用於&x的輸出。%u是十進位無號整數之格式印出。%p則是十六進位。


前提:指標是call by address. 所以只要改變副程式的值就改變主程式的值。
簡單指標的方法:
(1)int *ptri //宣告一個整數指標ptri。
(2)ptri=&sum //將sum位址設指標ptri存放。
(3)此時*ptri的值=sum的值,ptri的值=sam的位址,&ptri的值=新一個位址。
(4)值得注意的是在宣告int *ptri的時候,其宣告之後還沒有設值,但是可能會有值,原因為可能是記憶体內留有殘值。
(5)值得一提的是宣告一整數變數時,其所指向該變數的指標型態也要是整數。
_____________________________________________________________________
再來介紹的是:位址運算值「&」與依址取值運算值「*」。

位址運算值「&」

&是將變數或陣列元素的位址取出,所以不並不適用在常數或是運算式,如&100、&(i++)等,這都是不合法的使用。

依址取值運算值「*」
沒有什麼好介紹的。

______________________________________________________________________________

(1)特殊用法:
int a,*ptr1,*ptr2;
ptr1=&a;
ptr2=ptr1;
上述的程式,會等於
int a,*ptr1,*ptr2;
ptr1=&a;
ptr2=&a;

________________________________________________________________________________
(2)注意事項:
使用指標時要特別小心,最好在程式中一經過宣告後,立刻將指標指向正確的變數,如果無法一開始就讓指標設值的話,最好利用NULL使指標不指向任何記憶體位址。例如:
int a,*ptr1,*ptr2;
ptr1=&a;
ptr2=NULL;

學習matlab

一些指令,要慢慢累積。
(1)unique()→把相異的數,秀出來。
(2)length()→把一個陣列的個數秀出來。
舉例:
a=[1 1 2 5 6 6]
unique(a)→a=[1 2 5 6]
length(a)→a=6

應用方面:
要計算一個龐大且裏面有相同數目數量有多少?(不用計算重覆的)
length(unique(a))→4

再來介紹一下length(1,:)或是length(:,1)或是length(:,:)或是length(1,1)
第一個length(1,:)→1 1 2 5 6 6 (註是x軸的)
第二個length(:,1)→1(註是y軸的)
第三個length(:,:)→指全部。
第四個length(1,1)→1(座標1,1的位置)