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
- Formula Display
- Matrix
- Unit converter
- 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
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:
Conventions for Creating Initializers
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
{
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
(BOOL)isEqual:(id)anObject
In NSObject, this method is defined to return YES if and only if the receiver and anObject are the same object—that is, if both are pointers to the same memory location.
Clearly, this is not always the equal that you would hope for, so this method is overridden by many classes to implement a more appropriate idea of equality. For example, NSString overrides the method to compare the characters in the receiver and anObject. If they have the same characters in the same order, the two strings are considered equal.
Thus, if x and y are NSStrings, there is a big difference between these two expressions:
x == y
and
[x isEqual:y]
The first expression compares the two pointers. The second expression compares the characters in the strings. Note, however, that if x and y are instances of a class that has not overridden NSObject's isEqual: method, the two expressions are equivalent.
Clearly, this is not always the equal that you would hope for, so this method is overridden by many classes to implement a more appropriate idea of equality. For example, NSString overrides the method to compare the characters in the receiver and anObject. If they have the same characters in the same order, the two strings are considered equal.
Thus, if x and y are NSStrings, there is a big difference between these two expressions:
x == y
and
[x isEqual:y]
The first expression compares the two pointers. The second expression compares the characters in the strings. Note, however, that if x and y are instances of a class that has not overridden NSObject's isEqual: method, the two expressions are equivalent.
Convert between C string and NSString
Declare and define a string
Convert
// C string
char *foo;
// NSString
NSString *bar;
foo = "this is a C string";
bar = @"this is an NSString";
Convert
const char *foo = "Blah blah";
NSString *bar;
// Create an NSString from a C string
bar = [NSString stringWithUTF8String:foo];
// Create a C string from an NSString
foo = [bar UTF8String];
Saturday, November 22, 2008
Outlets & Actions
- Outlets
- Instance variables that are pointers to other objects are called outlets.
- Actions
- Methods that can be triggered by user interface objects are called actions.
How to learn
Inevitably, the people who get the most from the class share one characteristics: They remain focus on the topic at hand.
The first trick to maintain focus is to get enough sleep.
The second trick is to stop thinking about yourself.
The first trick to maintain focus is to get enough sleep.
The second trick is to stop thinking about yourself.
Cocoa Promise
Most of the time, Cocoa fulfills the promise: Common things are easy, and uncommon things are possible. If you find youself writing many lines of codes to do something rather ordinary, you are probably on the wrong track.
Saturday, November 15, 2008
nipotent
An element a of a ring is nilpotent is an = 0R for some positive integer n.
Some interesting characteristics related to ring
R has no nonzero nilpotent elements if and only if 0R is the unique solution of the equation x2 = 0R.
Let a and b be nilpotent elements in a commutative R. a + b and ab are also nilpotent.
Let N be the set of all nilpotent elements of R. N is a subring of R.
Some interesting characteristics related to ring
R has no nonzero nilpotent elements if and only if 0R is the unique solution of the equation x2 = 0R.
Let a and b be nilpotent elements in a commutative R. a + b and ab are also nilpotent.
Let N be the set of all nilpotent elements of R. N is a subring of R.
Friday, November 14, 2008
First Isomorphism Theorem
This theorem may be of great use when dealing with computer graphics
The natural homomorphism π is Theorem 6.12 is a special case of more general situation. If f:R → S is a surjective homomorphism of rings, we say that S is homomorphic image of R. if f is a actually an isomorphism (so that S is an isomorphic image of R), then we know that R and S have identical structure. Whenever one of them has a particular algebraic property, the other one has it too. If f is not an isomorphism, then properties of on thing may not hold in the other. However, the properties of S and the homomorphism f often gives us some useful information about R. An analogy with sculpture and photography may be helpful: If f: R → S is an isomorphism, then S is an exact, three-dimensional replica of R. If f is only a surjective homomorphism, then S is a two-dimensional photographic image of F in which some features of R are accurately reflected but others distorted or missing. The next theorem tells us precisely how R, S, and the kernel of f are related in these circumstances.
The theorem states that every homomorphic image of a ring R is isomorphic to a quotient ring R/K for some ideal K. Thus if you know all the quotient rings of R, then you know all the possible homomorphic images of R. The ideal K measures how much information iis lost in passing from the ring R to the homomorphic image R/K. When K = (0R), then f is an isomorphism by Theorem 6.11, and no information is lost. But when K i large, quite a bit may be lost.
The natural homomorphism π is Theorem 6.12 is a special case of more general situation. If f:R → S is a surjective homomorphism of rings, we say that S is homomorphic image of R. if f is a actually an isomorphism (so that S is an isomorphic image of R), then we know that R and S have identical structure. Whenever one of them has a particular algebraic property, the other one has it too. If f is not an isomorphism, then properties of on thing may not hold in the other. However, the properties of S and the homomorphism f often gives us some useful information about R. An analogy with sculpture and photography may be helpful: If f: R → S is an isomorphism, then S is an exact, three-dimensional replica of R. If f is only a surjective homomorphism, then S is a two-dimensional photographic image of F in which some features of R are accurately reflected but others distorted or missing. The next theorem tells us precisely how R, S, and the kernel of f are related in these circumstances.
- THEOREM 6.13 (FIRST ISOMORPHISM THEOREM)
- Let f:R → S be a surjective homomorphism of rings with kernel K. Then the quotient ring R / K is isomorphic to S.
The theorem states that every homomorphic image of a ring R is isomorphic to a quotient ring R/K for some ideal K. Thus if you know all the quotient rings of R, then you know all the possible homomorphic images of R. The ideal K measures how much information iis lost in passing from the ring R to the homomorphic image R/K. When K = (0R), then f is an isomorphism by Theorem 6.11, and no information is lost. But when K i large, quite a bit may be lost.
Tuesday, November 4, 2008
Sunday, November 2, 2008
The structure of Zp when p is prime
- THEOREM 2.8
- If p > 1 is an integer, then the following
- p is prime.
- For any a ≠ 0 in Zp, the equation ax = 1 has solution in Zp.
- Whenever ab = 0 in Zp, then a = 0 or b = 0.
- COROLLARY 2.9
- Let p be a positive. For any a ≠ 0 and any b in Zp, the equation ax = b has a unique solution in Zp.
- COROLLARY 2.10
- Let a, b, n be integer with n > 1 and (a, n) = 1. Then the equation [a]x = [b] has a unique solution in Zn.
- THEOREM 2.11
- Let a, b, n be integers with n > 1 and let d = (a, n). Then
- The equation [a]x = [b] has solutions in Zn if and only if d|b.
- If d|b, then the equation [a]x = [b] has d distinct solutions in Zn.
Subscribe to:
Posts (Atom)