This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @implementation NSFileHandle (print) | |
| - (void) printf: (NSString*) format, ... | |
| { | |
| NSString *output; | |
| va_list ap; | |
| va_start(ap, format); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void) awakeFromNib { | |
| self.opaque = YES; | |
| self.clearsContextBeforeDrawing = YES; | |
| [self setNeedsDisplay]; | |
| NSBundle *main = [NSBundle mainBundle]; | |
| // Open PDF | |
| CGPDFDocumentRef doc = CGPDFDocumentCreateWithURL((CFURLRef)[main URLForResource: @"NC.pdf" withExtension: nil]); | |
| if (doc == NULL) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| + pieSliceWithCentre: (CGPoint) c innerRadius: (double) ir outerRadius: (double) or | |
| startAngle: (double) theta1 endAngle: (double) theta2 { | |
| UIBezierPath *path = [UIBezierPath bezierPath]; | |
| if (path) { | |
| [path moveToPoint: CGPointMake(cos(theta1)*ir, sin(theta1)*or)]; | |
| [path addLineToPoint: CGPointMake(cos(theta1)*or, sin(theta1)*or)]; | |
| [path addArcWithCenter: CGPointZero radius: or startAngle: theta1 endAngle: theta2 clockwise: NO]; | |
| [path addLineToPoint: CGPointMake(cos(theta2)*ir, sin(theta2)*ir)]; | |
| [path addArcWithCenter: CGPointZero radius: ir startAngle: theta2 endAngle:theta1 clockwise: NO]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DECLARE FUNCTION atan2! (y AS DOUBLE, x AS DOUBLE) | |
| DECLARE SUB PieSlice2 (theta1 AS SINGLE, theta2 AS SINGLE, x AS SINGLE, y AS SINGLE, ro AS SINGLE, ri AS SINGLE) | |
| DECLARE SUB PieSlice (theta1 AS SINGLE, theta2 AS SINGLE, x AS SINGLE, y AS SINGLE, orad AS SINGLE, irad AS SINGLE) | |
| ' for PieSlice2 | |
| CONST sep = 10 | |
| DEF fnphi (x!, ri!) = ATN(x! / (2 * ri)) | |
| DEF fnAx (theta!, ri!) = ri! * COS(theta! + fnphi(sep, ri!)) | |
| DEF fnAy (theta!, ri!) = ri! * SIN(theta! + fnphi(sep, ri!)) | |
| DEF fnBx (theta!, ri!) = ri! * COS(theta! - fnphi(sep, ri!)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| float inputX[4] = { 2, 4, 8, 16 }; | |
| float inputY[4] = { 2, 4, 8, 16 }; | |
| float resultZ[4] = { 0, 0, 0, 0 }; | |
| float32x4_t sample1, sample2, result; | |
| sample1 = vld1q_f32(inputX); | |
| sample2 = vld1q_f32(inputY); | |
| result = vmulq_f32(sample1, sample2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require("string") | |
| state = {} | |
| function love.load() | |
| state.size = { cx = love.graphics.getWidth(), cy = love.graphics.getHeight() } | |
| -- ball is a position, a mass, and a velocity | |
| state.ball = { position = { x = state.size.cx / 2, y = state.size.cy / 2 }, | |
| mass = 50, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function math.clamp(v, min, max) | |
| if v > max then | |
| return max | |
| elseif v < min then | |
| return min | |
| else | |
| return v | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| subroutine step(positions, velocities) | |
| real, dimension(p,2), intent(inout) :: positions, velocities | |
| ! verify lengths (? unnecessary?) | |
| if (size(positions, 1) .ne. size(velocities, 1)) then | |
| print *, "The sizes of two arrays are not the same" | |
| end if | |
| ! move the particles to the new position | |
| do i = 1, size(positions, 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| program particles | |
| ! ten particles in a field of 10000 x 10000 | |
| ! base velocity is 10 x 10 | |
| integer, parameter :: p = 10, & | |
| fx = 10000, fy = 10000, & | |
| bx = 10, by = 10, & | |
| steps = 10000 | |
| real, parameter :: radius = 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function [x, y] = graph (varargin) | |
| list = varargin{1}; | |
| for i = 2:length(varargin) | |
| cat(1, list, varargin{i}); | |
| endfor | |
| x = list(1:rows(list), 1); | |
| y = list(1:rows(list), 2); | |
| x = cat(1, x, x(1)); | |
| y = cat(1, y, y(1)); |