Saturday, January 10, 2009

Array Initializaion


Aggregate initialization

Object [] a = {new Object(), new Object()};

Dynamic Aggregate Initialization

Object [] b;
b = new Object [] {new Object(), new Objet()};

Sunday, November 30, 2008

ill-conditioned is a least-squares problem

In same cases, the normal equations for a least-squares problem can be ill-conditioned; that is, small errors in the calculations of the entries of ATA can sometimes cause relatively large errors in the solution ˆx. If the columns of A are linearly independent, the least-squares solution can often be computed more reliably through a QR factorization of A.

Features of a Calculator


  1. Formula Display
  2. Matrix
  3. Unit converter
  4. Constant Search and Use

To be continued...

Friday, November 28, 2008

Types and Contants in Objective-C

Objective-C programmers use a few types that are not found in the rest of the C world.

  • id is a pointer to any type of object
  • BOOL is the same as char, but is used as a Boolean value.
    YES is 1.
    NO is 0.
  • IBOutlet is a macro that evaluates to nothing. Ignore it. (IBOutlet is a hint to Interface Builder when it reads the declaration of a class from a .h file.)
  • IBAction is the same as void. It also acts as a hint to Interface Builder.
  • nil is the same as NULL. We use nil instead of NULL for pointers to objects.

Sunday, November 23, 2008

Some special concepts in Objective-C

The definition is to be filled

selector

message

id

receiver&sender

Initializer

A few of the initializers in Cocoa will return nil if initialization was impossible. A programmer who is worried that the superclass's initializer may be one of these cases will create an initializer that is something like this:



- (id)init
{
if (![super init])
return nil;

firstNumber = random() % 100 + 1;
secondNumber = random() % 100 + 1;
return self;
}


This version will always work and is considered the most correct form; however, none of the classes that you will subclass in this book require these checks. For simplicity, this book will sometimes leave out the check.


Conventions for Creating Initializers


Following are rules that Cocoa programmers try to follow regarding initializers.


  • You do not have to create any initializer in your class if the superclass's initializers are sufficient.

  • If you decide to create an initializer, you must override the superclass's designated initializer.

  • If you create multiple initializers, only one does the work—the designated initializer. All other initializers call the designated initializer.

  • The designated initializer of your class will call its superclass's designated initializer.


The day will come when you will create a class that must, must, must have an argument supplied. Override the superclass's designated initializer to throw an exception:

- (id)init
{
[self dealloc];
@throw [NSException exceptionWithName:@"BNRBadInitCall"
reason:@"Initialize Lawsuit with initWithDefendant:"
userInfo:nil];
return nil;
}

Possible Tokens in the Calendar Format String

Possible Tokens in the Calendar Format String
SymbolMeaning
%yYear without century (00–99)
%YYear with century ("1990")
%bAbbreviated month name ("Jan")
%BFull month name ("January")
%mMonth as a decimal number (01–12)
%aAbbreviated weekday name ("Fri")
%AFull weekday name ("Friday")
%wWeekday as a decimal number (0–6), where Sunday is 0
%dDay of the month as a decimal number (01–31)
%eSame as %d but does not print the leading 0
%jDay of the year as a decimal number (001–366)
%HHour based on a 24-hour clock as a decimal number (00–23)
%IHour based on a 12-hour clock as a decimal number (01–12)
%pA.M./P.M. designation for the locale
%MMinute as a decimal number (00–59)
%SSecond as a decimal number (00–59)
%FMilliseconds as a decimal number (000–999)
%xDate using the date representation for the locale
%XTime using the time representation for the locale
%cShorthand for %X %x, the locale format for date and time
%ZTime zone name
%zTime zone offset in hours and minutes from GMT (HHMM)
%%A % character