Wednesday, 9 April 2008

manipulation of multi-dimensional array

Source:http://www.utdallas.edu/~rxc064000/dynamic_multi_dim.htm

23.1: Multidimensional Arrays and Functions

The most straightforward way of passing a multidimensional array to a function is to declare it in exactly the same way in the function as it was declared in the caller. If we were to call

func(a2);

then we might declare

func(int a[5][7])
{
...
}

and it's clear that the array type which the caller passes is the same as the type which the function func accepts.

If we remember what we learned about simple arrays and functions, however, two questions arise. First, in our earlier function definitions, we were able to leave out the (single) array dimension, with the understanding that since the array was really defined in the caller, we didn't have to say (or know) how big it is. The situation is the same for multidimensional arrays, although it may not seem so at first. The hypothetical function func above accepts a parameter a, where a is an array of 5 things, where each of the 5 things is itself an array. By the same argument that applies in the single-dimension case, the function does not have to know how big the array a is, overall. However, it certainly does need to know what a is an array of. It is not enough to know that a is an array of "other arrays"; the function must know that a is an array of arrays of 5 ints. The upshot is that although it does not need to know how many "rows" the array has, it does need to know the number of columns. That is, if we want to leave out any dimensions, we can only leave out the first one:

func(int a[][7])
{
...
}

The second dimension is still required. (For a three- or more dimensional array, all but the first dimension are required; again, only the first dimension may be omitted.)

The second question we might ask concerns the equivalence between pointers and arrays. We know that when we pass an array to a function, what really gets passed is a pointer to the array's first element. We know that when we declare a function that seems to accept an array as a parameter, the compiler quietly compiles the function as if that parameter were a pointer, since a pointer is what it will actually receive. What about multidimensional arrays? What kind of pointer is passed down to the function?

The answer is, a pointer to the array's first element. And, since the first element of a multidimensional array is another array, what gets passed to the function is a pointer to an array. If you want to declare the function func in a way that explicitly shows the type which it receives, the declaration would be

func(int (*a)[7])
{
...
}

The declaration int (*a)[7] says that a is a pointer to an array of 7 ints. Since declarations like this are hard to write and hard to understand, and since pointers to arrays are generally confusing, I recommend that when you write functions which accept multidimensional arrays, you declare the parameters using array notation, not pointer notation.

What if you don't know what the dimensions of the array will be? What if you want to be able to call a function with arrays of different sizes and shapes? Can you say something like

func(int x, int y, int a[x][y])
{
...
}

where the array dimensions are specified by other parameters to the function? Unfortunately, in C, you cannot. (You can do so in FORTRAN, and you can do so in the extended language implemented by gcc, and you will be able to do so in the new version of the C Standard ("C9X") to be completed in 1999, but you cannot do so in standard, portable C, today.)

Finally, we might explicitly note that if we pass a multidimensional array to a function:

int a2[5][7];
func(a2);

we can not declare that function as accepting a pointer-to-pointer:

func(int **a) /* WRONG */
{
...
}

As we said above, the function ends up receiving a pointer to an array, not a pointer to a pointer.

23.2: Dynamically Allocating Multidimensional Arrays

We've seen that it's straightforward to call malloc to allocate a block of memory which can simulate an array, but with a size which we get to pick at run-time. Can we do the same sort of thing to simulate multidimensional arrays? We can, but we'll end up using pointers to pointers.

If we don't know how many columns the array will have, we'll clearly allocate memory for each row (as many columns wide as we like) by calling malloc, and each row will therefore be represented by a pointer. How will we keep track of those pointers? There are, after all, many of them, one for each row. So we want to simulate an array of pointers, but we don't know how many rows there will be, either, so we'll have to simulate that array (of pointers) with another pointer, and this will be a pointer to a pointer.

This is best illustrated with an example:

#include

int **array;
array = malloc(nrows * sizeof(int *));
if(array == NULL)
{
fprintf(stderr, "out of memory\n");
exit or return
}
for(i = 0; i < nrows; i++)
{
array[i] = malloc(ncolumns * sizeof(int));
if(array[i] == NULL)
{
fprintf(stderr, "out of memory\n");
exit or return
}
}

array is a pointer-to-pointer-to-int: at the first level, it points to a block of pointers, one for each row. That first-level pointer is the first one we allocate; it has nrows elements, with each element big enough to hold a pointer-to-int, or int *. If we successfully allocate it, we then fill in the pointers (all nrows of them) with a pointer (also obtained from malloc) to ncolumns number of ints, the storage for that row of the array. If this isn't quite making sense, a picture should make everything clear:


Once we've done this, we can (just as for the one-dimensional case) use array-like syntax to access our simulated multidimensional array. If we write

array[i][j]

we're asking for the i'th pointer pointed to by array, and then for the j'th int pointed to by that inner pointer. (This is a pretty nice result: although some completely different machinery, involving two levels of pointer dereferencing, is going on behind the scenes, the simulated, dynamically-allocated two-dimensional "array" can still be accessed just as if it were an array of arrays, i.e. with the same pair of bracketed subscripts.)

If a program uses simulated, dynamically allocated multidimensional arrays, it becomes possible to write "heterogeneous" functions which don't have to know (at compile time) how big the "arrays" are. In other words, one function can operate on "arrays" of various sizes and shapes. The function will look something like

func2(int **array, int nrows, int ncolumns)
{
}

This function does accept a pointer-to-pointer-to-int, on the assumption that we'll only be calling it with simulated, dynamically allocated multidimensional arrays. (We must not call this function on arrays like the "true" multidimensional array a2 of the previous sections). The function also accepts the dimensions of the arrays as parameters, so that it will know how many "rows" and "columns" there are, so that it can iterate over them correctly. Here is a function which zeros out a pointer-to-pointer, two-dimensional "array":

void zeroit(int **array, int nrows, int ncolumns)
{
int i, j;
for(i = 0; i < nrows; i++)
{
for(j = 0; j < ncolumns; j++)
array[i][j] = 0;
}
}

Finally, when it comes time to free one of these dynamically allocated multidimensional "arrays," we must remember to free each of the chunks of memory that we've allocated. (Just freeing the top-level pointer, array, wouldn't cut it; if we did, all the second-level pointers would be lost but not freed, and would waste memory.) Here's what the code might look like:

for(i = 0; i < nrows; i++)
free(array[i]);
free(array);

Tuesday, 1 April 2008

Parsing arguments for your shell script

Parsing arguments for your shell script
By Carl Albing, JP Vossen, and Cameron Newham on July 17, 2007 (4:00:00 PM)
Source: http://www.linux.com/feature/118031


Suppose you want to have some options on your bash shell script, some flags that you can use to alter its behavior. You could do the parsing directly, using ${#} to tell you how many arguments have been supplied, and testing ${1:0:1} to test the first character of the first argument to see if it is a minus sign. You would need some if/then or case logic to identify which option it is and whether it takes an argument. What if the user doesn't supply a required argument? What if the user calls your script with two options combined (e.g., -ab)? Will you also parse for that? The need to parse options for a shell script is a common situation. Lots of scripts have options. Isn't there a more standard way to do this?

This article is excerpted from the newly published book bash Cookbook.

The solution -- use bash's built-in getopts command to help parse options. Here is an example, based largely on the example in the manpage for getopts

#!/usr/bin/env bash
# cookbook filename: getopts_example
#
# using getopts
#
aflag=
bflag=
while getopts 'ab:' OPTION
do
case $OPTION in
a) aflag=1
;;
b) bflag=1
bval="$OPTARG"
;;
?) printf "Usage: %s: [-a] [-b value] args\n" $(basename $0) >&2
exit 2
;;
esac
done
shift $(($OPTIND - 1))

if [ "$aflag" ]
then
printf "Option -a specified\n"
fi
if [ "$bflag" ]
then
printf 'Option -b "%s" specified\n' "$bval"
fi
printf "Remaining arguments are: %s\n" "$*"

There are two kinds of options supported here. The first and simpler kind is an option that stands alone. It typically represents a flag to modify a command's behavior. An example of this sort of option is the -l option on the ls command. The second kind of option requires an argument. An example of this is the mysql command's -u option, which requires that a username be supplied, as in mysql -u sysadmin. Let's look at how getopts supports the parsing of both kinds.

The use of getopts has two arguments.

getopts 'ab:' OPTION

The first is a list of option letters. The second is the name of a shell variable. In our example, we are defining -a and -b as the only two valid options, so the first argument in getopts has just those two letters -- and a colon. What does the colon signify? It indicates that -b needs an argument, just like -u username or -f filename might be used. The colon needs to be adjacent to any option letter taking an argument. For example, if only -a took an argument we would need to write 'a:b' instead.

The getopts built-in will set the variable named in the second argument to the value that it finds when it parses the shell script's argument list ($1, $2, etc.). If it finds an argument with a leading minus sign, it will treat that as an option argument and put the letter into the given variable ($OPTION in our example). Then it returns true (i.e., 0) so that the while loop will process the option then continue to parse options by repeated calls to getopts until it runs out of arguments (or encounters a double minus -- to allow users to put an explicit end to the options). Then getopts returns false (i.e., non-zero) and the while loop ends.

Inside the loop, when the parsing has found an option letter for processing, we use a case statement on the variable $OPTION to set flags or otherwise take action when the option is encountered. For options that take arguments, that argument is placed in the shell variable $OPTARG (a fixed name not related to our use of $OPTION as our variable). We need to save that value by assigning it to another variable because as the parsing continues to loop, the variable $OPTARG will be reset on each call to getopts.

The third case of our case statement is a question mark, a shell pattern that matches any single character. When getopts finds an option that is not in the set of expected options ('ab:' in our example) then it will return a literal question mark in the variable ($OPTION in our example). So we could have made our case statement read \?) or '?') for an exact match, but the ? as a pattern match of any single character provides a convenient default for our case statement. It will match a literal question mark as well as matching any other single character.

In the usage message that we print, we have made two changes from the example script in the manpage. First, we use $(basename $0) to give the name of the script without all the extra pathnames that may have been part of how it was invoked. Secondly, we redirect this message to standard error (>&2) because that is really where such messages belong. All of the error messages from getopts that occur when an unknown option or missing argument is encountered are always written to standard error. We add our usage message to that chorus.

When the while loop terminates, we see the next line to be executed is:

shift $(($OPTIND - 1))

which is a shift statement used to move the positional parameters of the shell script from $1, $2, etc. down a given number of positions (tossing the lower ones). The variable $OPTIND is an index into the arguments that getopts uses to keep track of where it is when it parses. Once we are done parsing, we can toss all the options that we've processed by doing this shift statement. For example, if we had this command line:

myscript -a -b alt plow harvest reap

then after parsing for options, $OPTIND would be set to 4. By doing a shift of three ($OPTIND-1) we would get rid of the options and then a quick echo$* would give this:

plow harvest reap

So, the remaining (non-option) arguments are ready for use in your script (in a for loop perhaps). In our example script, the last line is a printf showing all the remaining arguments.

Monday, 1 October 2007

lib for the image processing stuff

This is the library file for that image processing project.

-- PPMlib.hs
-- Library for 433-152 Project 2007
-- Bernard Pope

module PPMlib where

import Text.ParserCombinators.Parsec

type Pixel = (Int, Int, Int)

data PPM
= PPM Int Int Int [Pixel]
deriving Show

getPixels :: PPM -> [Pixel]
getPixels (PPM _ _ _ ps) = ps

getWidth :: PPM -> Int
getWidth (PPM w _ _ _) = w

getHeight :: PPM -> Int
getHeight (PPM _ h _ _) = h

getMaxVal :: PPM -> Int
getMaxVal (PPM _ _ m _) = m

{- transform interface
example: transform verify greyScale "in.ppm" "out.ppm"
-}

transform :: (PPM -> Maybe String) -> (PPM -> PPM) -> String -> String -> IO ()
transform verify trans inFile outFile = do
result <- parser inFile
case result of
Left e -> print e
Right ppm -> do
case verify ppm of
Nothing -> do
let newPPM = trans ppm
case verify newPPM of
Nothing -> writeFile outFile $ pretty newPPM
Just err -> do
putStrLn "Error in transformed image"
putStrLn err
Just err -> do
putStrLn "Error in input image"
putStrLn err

{- pretty printing PPM files -}

pretty :: PPM -> String
pretty (PPM width height maxVal pixels)
= "P3 " ++ unwords [show width, show height] ++ "\n" ++
unlines (show maxVal : prettyPixels pixels)
where
prettyPixels :: [Pixel] -> [String]
prettyPixels = map prettyPixel
prettyPixel :: Pixel -> String
prettyPixel (r,g,b) = unwords $ map show [r,g,b]

{- parsing PPM files -}

parser :: String -> IO (Either ParseError PPM)
parser = parseFromFile parsePPM

parsePPM :: Parser PPM
parsePPM = do
string "P3"
junk
width <- parseInt
junk
height <- parseInt
junk
maxVal <- parseInt
junk
pixels <- many parseTriplet
return $ PPM width height maxVal pixels

comment :: Parser ()
comment = do
char '#'
manyTill anyChar newline
spaces

junk :: Parser ()
junk = do
spaces
optional comment

parseTriplet :: Parser (Int, Int, Int)
parseTriplet = do
red <- parseInt
spaces
green <- parseInt
spaces
blue <- parseInt
spaces
return (red, green, blue)

parseInt :: Parser Int
parseInt = do
ds <- many1 digit
return $ read ds

my Proj.hs

This is our project for 433-152: Algorithmic Problem Solving. Had finished the 8 functions a few days before, but found that the pictures my program generated were different from the example files provided using the Unix tool 'diff'. Then I spent about 8 hours fixing and debugging. This was really painful! I struggled for two hours just with the order of base case for 'enlarge'! I should have put it before the main body of the function but didn't realize that! WTF!! Okay, I'll cut my crap, it's the project main file Proj.hs. I'll put the library file on here using another blog entry. Take a look at it if you're interested in Haskell or image processing!


-- Proj.hs
-- Your file for 433-152 Project 2007
-- Stub code by Bernard Pope and Anthony Wirth

module Proj where

import PPMlib
import Data.Map hiding (map)

type Coord = (Int, Int)

noVerify :: PPM -> Maybe String
noVerify _ = Nothing

verify :: PPM -> Maybe String
verify (PPM w h m pixel) =
-- if there's at least one wrong pixel, return error msg otherwise return Nothing
if (and (map (verify' w h m) pixel) == False) then Just "Invalid PPM file" else Nothing
-- see whether the attributes of the picture are valid
where
verify' w h m (r, g, b)
| g > m || r > m || b > m = False
| g < 0 || r < 0 || b < 0 = False
| w < 0 || h < 0 || m < 0 = False
| otherwise = True


-- simple one!
greyScale :: PPM -> PPM
greyScale (PPM w h m pixel) =
PPM w h m (map change pixel)
where
change :: (Int, Int, Int) -> (Int, Int, Int)
change (r, g, b) = (grey, grey, grey)
where
-- grey = floor (0.3 * (fromIntegral (r::Int)) + 0.59 * (fromIntegral (g::Int)) + 0.11 * (fromIntegral (b::Int)))
grey = div (r + b + g) 3


-- mothod is like the one above.
negative :: PPM -> PPM
negative (PPM w h m pixel) =
PPM w h m (map (invert m) pixel)
where
invert :: Int -> (Int, Int, Int) -> (Int, Int, Int)
invert m (a, b, c) = (m - a, m - b, m - c)

-- Stupid way which I used at first!
-- inverter m ([]) = []
-- inverter m ((a, b, c) : rest) = (m - a, m - b, m - c) : (inverter m rest)


-- This seems perfectly right, but it never stops when run.
-- replicate and concat
-- replicate n : get a list of n duplicated items
-- concat : convert a list of tuples into a list with all the original iterms
-- (left, right) = splitAt halfway pixel. this is a really useful way, learnt from the lecture. A good way to split things up.
enlarge :: Int -> PPM -> PPM
enlarge n (PPM w h m pixel) =
PPM (w * n) (h * n) m (vertical w n (horizontal n pixel))
-- horizontally stretching
horizontal :: Int -> [(Int, Int, Int)] -> [(Int, Int, Int)]
horizontal n pixel = concat $ map (replicate n) pixel
-- vertically stretching
-- duplicate each row and append the handled rest to it
vertical :: Int -> Int -> [(Int, Int, Int)] -> [(Int, Int, Int)]
vertical w n [] = []
vertical w n pix = (concat $ replicate n row) ++ (vertical w n rest)
where
(row, rest) = splitAt (n * w) pix

--crap this is what I did at first, obviously it's wrong
--concat $ map (replicate n) pixel
--concat (map (replicate n) pixel)


-- I have an idea, but don't know how to write code for it.
-- I take the average value of the corresponding pixels and let it be the new pixel.
-- What I'm not sure is, what if w or h is not divisible by n? How to handle the remainder?
reduce :: Int -> PPM -> PPM
reduce _ _ = undefined


-- reconstruct rows in the reverse order, pretty simple.
reflectRow :: PPM -> PPM
reflectRow (PPM w h m pixel) =
PPM w h m (reflect w pixel)
reflect :: Int -> [a] -> [a]
-- base case
reflect w [] = []
-- append rows from the bottom to the top
reflect w pixel = (reflect w right) ++ left
where
(left, right) = splitAt w pixel


-- reverse all the pixels in each row and then append all the rows together!
reflectCol :: PPM -> PPM
reflectCol (PPM w h m pixel) =
PPM w h m (revcol w pixel)
revcol :: Int -> [a] -> [a]
revcol w [] = []
-- reverse and append
revcol w pixel = (reverse left) ++ (revcol w right)
where
(left, right) = splitAt w pixel

-- Really don't know how to do it
rotate :: Float -> Coord -> PPM -> PPM
rotate _ _ _ = undefined


-- a pretty easy one, used the function min
threshold :: Int -> PPM -> PPM
threshold t (PPM w h m pixel) =
PPM w h m (map change pixel)
where
change :: (Int, Int, Int) -> (Int, Int, Int)
change (a, b, c) = ((min t a), (min t b), (min t c))


-- First take out extra columns and then rows
crop :: Coord -> Coord -> PPM -> PPM
crop (a, b) (c, d) (PPM w h m pixel) =
PPM (d - b + 1) (c - a + 1) m (croprow h a c (d - b + 1) (cropcol w b d pixel))
-- eliminate columns that we don't need
cropcol w b d [] = []
cropcol w b d pix = image ++ (cropcol w b d rest)
where
-- get each row
(row, rest) = splitAt w pix
-- for each row, take out unwanted part to the left of the selected area
(junk1, rowrest) = splitAt b pix
-- for each row, take out the part to the right of the wanted image part
(image, junk2) = splitAt (d - b + 1) rowrest
--take out extra rows
croprow h a c w' [] = []
croprow h a c w' pix = image
where
-- extra rows above the selected image
(upperjunk, rest) = splitAt (a * w') pix
-- rows delow the wanted part of image
(image, lowerjunk) = splitAt (w' * (c - a + 1)) rest


translate :: Coord -> PPM -> PPM
translate (a, b) (PPM w h m pixel) =
PPM w h m (transrow w h a (transcol w b pixel))
-- move the left edge of the picture to the correct column.
transcol :: Int -> Int -> [(Int, Int, Int)] -> [(Int, Int, Int)]
transcol w b [] = []
transcol w b pix = case b >= 0 of
True -> black b ++ left ++ transcol w b rest
False -> rightn ++ black (-b) ++ transcol w b rest
where
(row, rest) = splitAt w pix
(left, right) = splitAt (w - b) row
(leftn, rightn) = splitAt (-b) row
-- move the top edge to the correct row.
transrow :: Int -> Int -> Int -> [(Int, Int, Int)] -> [(Int, Int, Int)]
transrow w h a [] = []
transrow w h a pix = case a >= 0 of
True -> black (a * w) ++ image
False -> uimage ++ black ((-a) * w)
where
(image, rest) = splitAt ((h - a) * w) pix
(urest, uimage) = splitAt ((-a) * w) pix
-- make black pixels
black :: Int -> [(Int, Int, Int)]
black 0 = []
black n = (0, 0, 0) : black (n - 1)


-- don't have enough time to do it.
normalize :: PPM -> PPM
normalize _ = undefined

Saturday, 25 August 2007

Plato's View that Philosophers Should Rule

The famous philosopher Plato holds that the world should be ruled by true philosophers. This idea involves a great deal of wisdom and have been studied by many philosophers. It will be discussed in this essay.

Plato not only has the opinion that philosophers should rule, but also has developed a whole theory to support this. According to Plato's masterpiece the Republic, there are three distinctions between philosophers and non-philosophers and these are important factors which to some extent, determine philosophers' absolute ruler position. Firstly, unlike most lovers of beautiful things, philosophers in addition love beauty itself, which is the Form introduced by Plato. Secondly, philosophers live in the real world, non-philosophers in their dream world. Lastly, philosophers are people who have true knowledge,, but counterfeit philosophers only have beliefs or opinions. Plato further conceives a model containing images of the Sun, the Line and the Cave to strengthen his theory. To elaborate, this model mainly illustrates the relation and difference between knowledge and ignorance, dream and reality.

As for Plato's viewpoint of distinctions between philosophers and non-philosophers, I argue that this is enough to note that philosophers should rule and they can run the world in the most balanced state. This is not purely because philosophers have knowledge, which others don't, but also because there are no better alternatives for them. Cross (1964) says that the difference between true philosophers and their rivals is that true philosophers know reality of which many counterfeit philosophers' 'reality' is appearance. This means true philosophers grasp the eternal and internal knowledge of things and this knowledge acts in real world as theorems and axioms do in mathematics. They are the rules that determine how everything in the world works. So a philosopher's mind is like an abstraction of non-philosopher's thoughts. But this kind of abstraction or high level of understanding is somewhat away from practice. They can't adjust their knowledge with times, so there exists a distance between their knowledge and the real world (Pappas, 1995). However, as is known to all, what play the fundamental role in the world are the natures of things and only philosophers can reach them. So despite their limitation of practical knowledge, philosophers are still more qualified to rule than any other people because they are fundamentally correct.

Plato's model of the Sun, the Line and the Cave also indicates that philosophers have the utmost intelligence and should rule the world. Because it basically shows different levels of the world – the visible and the intelligible. Cross (1964) perceives the model that those who stand at the top know the Form of the Good – the Sun, knowledge – the top of the Line, and truth – one who receives education and has broken out of the Cave. This model also to some degree, proves the point that philosophers being the rulers mainly because there are no better alternatives for them – they are on the top, despite the fact that this point of view might be slightly different from Plato's original meaning of philosophers being the rules.

All in all, although there might arise many explanations, there's an agreement that philosophers have the highest level of knowledge and should rule the world in order to achieve the most balanced state of the world.


References

Bobonich . C, “Why Should Philosophers Rule? Plato's Republic and Aristotle's Protrepticus”, Philosophy, Stanford University, Available at:
http://journals.cambridge.org/action/displayAbstract;jsessionid=11DEBBE7A2E0E52611522068E4C2DA0E.tomcat1?fromPage=online&aid=1031904

Cross. R. C, Plato's Republic – A Philosophical commentary, London, New York St Martin's Press, 1964.

Pappas Nickolas, Plato and the Republic, from the Republic of Plato translated by Allan Bloom, 1995.

Plato, The republic, edited by G.R.F. Ferrari ; translated by Tom Griffith, Published by New York. Cambridge University Press, 2000.

Tuesday, 26 June 2007

last sem's essay

Didn't do it very well, but yeh, at last I handed in a full draft. If you wanna reference, PLEASE CITE THE SOURCE.

Chinese Post World War II Immmigration



INTRODUCTION

After World War II, the reconstruction effort and low birthrate in Australia called for more immigrants. Although encouraging immigration under the White Australian Policy resulted in dramatic increase of overseas-born population according to a report from DIMIA (2003), during which Chinese people were looked down, it was not satisfactory enough. In this phase the need for a more diverse population was increasing. It was not until 1973 that the White Australian Policy was abolished (DIMIA, 2003) and it was not long before the policy of multiculturalism was introduced in 1978, after which Chinese migration started to fluctuate and made contributions to the society. This paper will discuss issues in the period before the policy of multiculturalism was introduced as well as the period after that. Firstly, it will focus on society's attitudes towards Chinese immigrants in terms of their social cultural and economic impact on the country. Secondly, governments' policies towards immigrants will be talked about.



AUSTRALIANS' ATTITUDES TOWARDS CHINESE

Chinese immigrants as well as other non-white immigrants were looked down and were not encouraged to come to Australia in the period immediately after World War II. This was because of the Immigration Restriction Act, which was introduced in 1901 and mainly aimed against Chinese (Chan, 2000). This kind of viewpoint didn't fade away even after World War II. Although Chinese were not treated as bad as they were in the gold rush period, they were still viewed as an inferior group. London (1970) argues that Chinese were perceived as a threat to Australia's cultural heritage and development because of their generally lower standard of living as a threat to labour employer relations. Goot (1978) also points out that the antipathy to Chinese migrants was generated by some considerations, like concerns about the costs of immigration and the competition for jobs. This kind of attitude could be perceived from Queensland Parliament's revoke of a legislation under which any house where Asian women lived could be viewed as a house of prostitution in 1966 (London, 1970). This was really a down point after World War II. However, some positive attitudes existed despite the fact that the overall attitude was negative. London (1970) has the opinion that Chinese later were gradually accepted by the cities’ resident in Melbourne and Sydney and Australians’ sympathetic support of China accelerated the assimilation process. This was the trend of the shift of Australians’ attitudes towards Chinese in that time period as well as the Integration period.

According to a review report from DIMIA (2003) – Report of the Review of Settlement Services for Migrants and Humanitarian Engrant, the situation didn’t change much until the introduction of multiculturalism by Galbally report in 1978. The result of assimilation and integration was not satisfactory in spite of the fact that Australia had paid a considerable amount of effort to policy making to encourage immigration in order to increase the country’s population. The multiculturalism policy gave rise to a large-scale Chinese migration. As a result, Australia had a very high Chinese migration intake over the past two decades. Those Chinese immigrants not only made a culturally and linguistically diverse population together with other groups of immigrants (DIMIA, 2003), but also contributed to Australian society, which changed Australians' attitudes towards Chinese people dramatically. Their contributions mainly fell into three categories – social, cultural and economic aspects.

From a social perspective, Chinese immigration during this time period really gave Australia a new look. In the first place, the large number of arrivals changed the make-up of the population dramatically. The number of Chinese immigrants was over 92,000, ranking second among all the Asian counties in 1995 (Millbank, 2001). Millbank (2001) also states that in this time period – 1995 to 1996, recent surge from mainland China and Hong Kong resulted in the fact that Northeast Asian settlers outnumbered Southeast Asian settlers, which reflected the current trend of Chinese migration into Australia. This was important because immigrants' average ages were below the Australian average, which could to some extent solve the aging problem of Australian population. In the second place, the large-scale immigration also resulted in more investment that government put on education, and made the quality of education higher, especially for language training. Immigrants came from different counties, so English was a second language for most of them. Hence paying attention to language training was essential and beneficial because this cleared the main obstacles and hurdles for immigrants to contribute to the society. Last but not least, according to APMRN (2004), the large-scale Chinese migration as well as immigration of other groups made the government have laws against racial discrimination and incitement and have special agencies to enforce them. This is, to some extent, an advance of the discrimination of racism.

China is famous for its mysterious 5000-year history and the culture developed during the long time period, so under the light of the multiculturalism policy Chinese people brought their culture to Australia, which had great effects on the society. Firstly, Chinese migrants brought various Chinese food and products into Australia, which gave Australians more choices on food and a chance to experience this special culture around the world. There were Chinatowns in major cities in Australia, hence many Australians who were keen on Chinese food or history could go to Chinatown for lunch or dinner with their families, which would be very fantastic. Secondly, some Chinese festivals and customs were taken into practice in many places in Australia. For instance, many Australians ate dumplings on New Year's Day in Australia. In addition, plenty of Australians had the preference for Chinese tea culture; they drank tea and talked about tea with friends in leisure time and enjoyed it pretty much. Thirdly, Chinese culture contributed to the ever-increasingly cultural diversity greatly because of the large intake of Chinese immigrants during this period..

Chinese immigration over the past twenty years benefited Australia’s economy a great deal. It mainly affected Australia’s economy in two ways, the demand side and the supply side (DIEA Fact Sheet30, 1995). DIEA fact sheet 30 (1995) also states that in terms of the demand side, the first factor is migrants own demands. Their needs for food, housing and leisure activities stimulated factories and companies to invest more money and to produce more products, the economy benefited from this to some extent. More arrivals meant that more heath, education and welfare services were needed, hence these aspects advanced due to the immigration. With regard to the supply side, the most direct benefit Chinese immigrants brought to Australia was workforce, skills and money. Workforce shortage could, to some extent, be solved through immigration of younger people. Skeldon (2004) points out that the majority of Chinese migrants today are highly educated or have specialized skills selected through a special “points” system, so immigrants with high business skills also contributed much to the economy. In addition, new business can be introduced into Australia. Chinese immigrants contributed a great deal in this aspect because China was quite different from western countries in terms of dressing, eating habits and so on. So some Chinese food such as noodles and tea, and Chinese featured clothes were introduced into Australia and the demands for these kinds of products definitely helped the development of the economy. From another perspective, this also added productive diversity through knowledge of international business markets. (DIEA Fact Sheet 30, 1995).



GOVERNMENT'S POLICIES FOR CHINESE AND OTHER IMMIGRANTS

Australian government made a series of policies on migration throughout the post World War II period according to the times. It fell into two phases. The first phase was the period before multiculturalism, the second - the period after that. As mentioned at the beginning of this paper, immigration immediately after the war followed the Immigration Restriction Act introduced in 1901, which was widely known as White Australian Policy. The government then realized that only European immigrants were not enough - Australia still in a desperate need for a large population. Also a review report from DIMIA (2003) says that the Commonwealth Government established DIMIA in order to assist migration into Australia due to the concerns regarding Australia’s low birthrate and strong need for industrial labour. Hence the government put forward the assimilation policy, after which many non-British migrants came to Australia. The scale of Chinese migration in this period wasn't large because Australians still perferred Europeans instead of Asians. Although Australia witnessed a higher intake of migrants, the assimilation policy was limited. So the government shifted from the policy of assimilation to a policy of integration. And during this period, due to the removal of discrimination from within the immigration program, the White Australian Policy was abolished in 1973 and equal treatment for immigrants from different origin became an official standard (DIMIA, 2003). As a result of the process of this removal of discrimination, the shift towards multiculturalism on a policy level was finally seen in 1978, which according to Elliot (1984) was also because of an economic factor. Elliot points out that Australia had to develop and maintain trading relations with some neighbour countries. If Australia’s immigration policy was discriminatory against migrants from those countries, it would definitely not only have a negative effect on Australian economy, but also would have some more serious problems.

After the introduction of multiculturalism – the start of the second phase, the country went through a dramatic change, and the government paid a great deal of effort to policy making to benefit from and also to support these changes. Firstly, the definition of multiculturalism was being completed and changed according to the contemporary situation. Three principles were adopted 1989 – cultural identity, social justice and economic efficiency (DIMA, 1999). Secondly, DIMA (1999) also says that in 1986, Jupp argued that successful settlement by non-English speaking migrants needed not only the effort of the migrants, but also the services provided by the host society. The government thus had access and equity policy to help immigrants to adjust to the diverse society more easily and more quickly. This policy, according to Jupp's report in 1986, included two main aspects. The first one was to equip overseas-born families and idividuals the basic resources to enable them to function effectively on an equitable level in Australian society. The second was on an institutional level – let institutions which made decisions about making services and providing them implement them on an equitable basis. This kind of policy have been playing an important role in Chinese immigration, or we wouldn't see so many things reflecting Chinese culture around us here in Australia. Thirdly, the Australian government noticed that it should enourage more skilled and educated people to come to Australia to contribute to the society. So the Australian government put forward a series of laws to help highly skilled individuals and successful businessmen to have permanent residence in Australia. According to the fact sheet Assisting Skilled and Business people (DIC), applicants are classified into several categories, skilled independent, state/territory nominated independent, skilled – Australian sponsored, etc. Obviously, the Australian Government paid a considerable amount of attention to absorbing high-tech people to boost Australian economy. Last but never least, the Australian government also set up a policy a to meet the Chinese increasing interest in visiting Australia. Fact Sheet 58 (DIMIA) states that as Australia was the first western country approved by Chinese government a destination for tourists, Australia has paid some effort to make it easier. Although this is not about migration, some tourists could be would-be immigrants because of the beauty and power of Australia. So this could encourage Chinese people to migrate to Australa to some extent.



CONCLUSION

Whilst Chinese immigrants didn't have a good reputation at the beginning of the second World War, they have been doing their best to get adjusted to the society and their contributions to the society in many aspects really made a difference. It's very pleased to see that Chinese people were gradually accepted by the Australian society and the Australian government has been trying to incease the diversity and scale of the population – going on with the multicultural policy.

Having considered the fact that Australia is still short of industrial labour and workforce, it's believed that government will have more policies on immigration to support highly skilled and educated people to come to Australia, and more corresponding policies that can solve problems caused by the immigration. And it's also believed that Chinese people will play a more important role in Australia and make as many contributions as they can to the society to meet the government's original intention.



REFERENCES

DIEA, Fact Sheet 30, 1995.

Asia Pacific Migration Research Network (APMRN), Migration Issues in the Asia Pacific, ISSUES PAPER FROM AUSTRALIA, [online] Available:
http://www.unesco.org/most/apmrnwp5.htm

Assisting Skilled and Business People, (Fact Sheet) Department of Immigration and Citizenship, Australian Government, [online] Available:
http://www.immi.gov.au/media/fact-sheets/48assisting.htm

China - Approved Destination Status, (Fact Sheet) Department of Immigration and Citizenship, Australian Government, [online] Available:
http://www.immi.gov.au/media/fact-sheets/58china.htm

Chan, H. (2000) From Quong Tarts to Victor Changes: Being Chinese In Australia in the Twentieth Century. CSCSD Public Seminar at the Australian National University. 24 May 2000.

DIMA, New Agenda for Multicultural Australia,
DIMA, Canberra, 1999, p. 8.

DIMIA, Report of the Review of Settlement Services for Migrants and Humanitarian Entrants, May 2003.

Elliot, J. D. (1984). Immigration: The economic benefits. In F. Milne & P. Shergold (Eds.), The great immigration debate. Sydney: Federation of Ethnic Communities in Australia.

Goot. M, Immigrations and Immigration: Evidence and Argument From the Public, 1943 – 1987, Macquarie University.

London. H. I., 1970, Non-White Immigration and the “White Australian” Policy.

Millbank, A, Asian Immigration, Current Issues Brief 16 1996-97, Social Policy Group, [online] Available:
http://www.aph.gov.au/library/pubs/cib/1996-97/97cib16.htm

Skeldon, R, 2004 China: From Exceptional Place to Global Participant. [online], Available:
http://www.migrationinformation.org/Feature/display.cfm?D=9 – 41k

Monday, 28 May 2007

reminder

Always remember the expression in terms of exponentials and the identity equations when dealing with trigonometric and hyperbolic functions!

The hyperbolic identity equation:
Coshx squre minus sinhx squre equals 1.

Coshx = 1/2 times the sum of e to the x and e to the negative x.
Sinhx = 1/2 times the result of e to the x minus e to the negative x.

The trigonometric identity equation:
Cosx squre plus sinx squre is equal to 1.

Sinx = 1/2 times the result of e to the power of ix take away e to the power of -ix.
Cosx = minus i/2 times the sum of e to the ix and e to the -ix.

I won't forget them hopefully.