Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -14,3 +14,21 @@ The four operations to be implemented are:
* Vector <big><b> / </b></big> scalar division
<br><br>
;Related tasks:
* &nbsp; [[Array]]
* &nbsp; [[Arrays]]
* &nbsp; [[Vector]]
* &nbsp; [[Matrices]]
* &nbsp; [[Dot product]]
* &nbsp; [[Vector products]]
* &nbsp; [[Bivector]]
* &nbsp; [[Antivector]]
* &nbsp; [[Tensor]]
* &nbsp; [[Quaternion]]
* &nbsp; [[Rotor]]
* &nbsp; [[Motor]]
* &nbsp; [[Sedenion]]
* &nbsp; [[Octonion]]
<br><br>

View file

@ -1,7 +1,7 @@
# the standard mode COMPLEX is a two element vector #
MODE VECTOR = COMPLEX;
# the operations required for the task plus many others are provided as standard for COMPLEX and REAL items #
# the to components are fields called "re" and "im" #
# the two components are fields called "re" and "im" #
# we can define a "pretty-print" operator: #
# returns a formatted representation of the vector #
OP TOSTRING = ( VECTOR a )STRING: "[" + TOSTRING re OF a + ", " + TOSTRING im OF a + "]";

View file

@ -1,31 +0,0 @@
with Ada.Text_IO;
procedure Vector_Demo is
type Vector is record
X, Y : Float;
end record;
function "+" (A, B : Vector) return Vector is
(A.X + B.X, A.Y + B.Y);
function "-" (A, B : Vector) return Vector is
(A.X - B.X, A.Y - B.Y);
function "*" (S : Float; A : Vector) return Vector is
(S * A.X, S * A.Y);
function "/" (A : Vector; S : Float) return Vector is
(A.X / S, A.Y / S);
procedure Print (A : Vector) is
begin
Ada.Text_IO.Put_Line ("(" & A.X'Image & "," & A.Y'Image & ")");
end Print;
Example : Vector := (1.0, 1.0);
begin
Print (Example + Example);
Print (Example - Example);
Print (2.0 * Example);
Print (Example / 2.0);
end Vector_Demo;

View file

@ -1,37 +1,34 @@
define :vector [
x y
][
print: -> render "(|this\x|, |this\y|)" ; prettyprint function
]
init: method [x,y][
this\x: x
this\y: y
]
ensureVector: function [block][
ensure -> every? @block => [is? :vector &]
]
add: method [that :vector][
to :vector @[this\x + that\x, this\y + that\y]
]
vadd: function [a b][
ensureVector [a b]
to :vector @[a\x + b\x, a\y + b\y]
]
sub: method [that :vector][
to :vector @[this\x - that\x, this\y - that\y]
]
vsub: function [a b][
ensureVector [a b]
to :vector @[a\x - b\x, a\y - b\y]
]
mul: method [n :integer][
to :vector @[this\x * n, this\y * n]
]
vmul: function [a n][
ensureVector [a]
to :vector @[a\x * n, a\y * n]
]
div: method [n :integer][
to :vector @[this\x // n, this\y // n]
]
vdiv: function [a n][
ensureVector [a]
to :vector @[a\x // n, a\y // n]
string: method [][
render "(|this\x|, |this\y|)"
]
]
; test our vector object
a: to :vector [5 7]
b: to :vector [2 3]
print [a '+ b '= vadd a b]
print [a '- b '= vsub a b]
print [a '* 11 '= vmul a 11]
print [a '/ 11 '= vdiv a 2]
print [a '+ b '= a + b]
print [a '- b '= a - b]
print [a '* 11 '= a * 11]
print [a '/ 11 '= a / 2]

View file

@ -1,67 +1,33 @@
#include <iostream>
#include <cmath>
#include <cassert>
using namespace std;
/*
* CXXFLAGS=-march=native -O3 -std=<c|gnu>++23 -mfpmath=<your SIMD implementation>
* compatible with every compiler and any SIMD platform.
* Based on aligned vector type using cstdout not iostream.
*/
#include "vec.hpp"
#define PI 3.14159265359
using f32 = float;
using f32x2 = vec<f32,2>;
class Vector
inline bool print_test(f32x2 a, f32x2 b);
int main(int argc, char** argv)
{
public:
Vector(double ix, double iy, char mode)
{
if(mode=='a')
{
x=ix*cos(iy);
y=ix*sin(iy);
}
else
{
x=ix;
y=iy;
}
}
Vector(double ix,double iy)
{
x=ix;
y=iy;
}
Vector operator+(const Vector& first)
{
return Vector(x+first.x,y+first.y);
}
Vector operator-(Vector first)
{
return Vector(x-first.x,y-first.y);
}
Vector operator*(double scalar)
{
return Vector(x*scalar,y*scalar);
}
Vector operator/(double scalar)
{
return Vector(x/scalar,y/scalar);
}
bool operator==(Vector first)
{
return (x==first.x&&y==first.y);
}
void v_print()
{
cout << "X: " << x << " Y: " << y;
}
double x,y;
};
f32x2 a = f32x2{ cosf( M_PIf/6), sinf( M_PIf/6) } * 3;
f32x2 b = f32x2{ cosf(2*M_PIf/3), sinf(2*M_PIf/3) } * 5;
int main()
{
Vector vec1(0,1);
Vector vec2(2,2);
Vector vec3(sqrt(2),45*PI/180,'a');
vec3.v_print();
assert(vec1+vec2==Vector(2,3));
assert(vec1-vec2==Vector(-2,-1));
assert(vec1*5==Vector(0,5));
assert(vec2/2==Vector(1,1));
return 0;
exit(print_test(a,b) ? EXIT_SUCCESS : EXIT_FAILURE);
}
inline bool print_test(f32x2 a, f32x2 b)
{
a.print(); fputs(" + ", stdout); b.print(); fputs(" = ", stdout);
(a + b).println();
a.print(); fputs(" - ", stdout); b.print(); fputs(" = ", stdout);
(a - b).println();
a.print(); fputs(" * 3 = ", stdout);
(a * 3.0f).println();
b.print(); fputs(" / 2.5 = ", stdout);
(b / 2.5f).println();
return true;
}

View file

@ -1,83 +0,0 @@
#include<stdio.h>
#include<math.h>
#define pi M_PI
typedef struct{
double x,y;
}vector;
vector initVector(double r,double theta){
vector c;
c.x = r*cos(theta);
c.y = r*sin(theta);
return c;
}
vector addVector(vector a,vector b){
vector c;
c.x = a.x + b.x;
c.y = a.y + b.y;
return c;
}
vector subtractVector(vector a,vector b){
vector c;
c.x = a.x - b.x;
c.y = a.y - b.y;
return c;
}
vector multiplyVector(vector a,double b){
vector c;
c.x = b*a.x;
c.y = b*a.y;
return c;
}
vector divideVector(vector a,double b){
vector c;
c.x = a.x/b;
c.y = a.y/b;
return c;
}
void printVector(vector a){
printf("%lf %c %c %lf %c",a.x,140,(a.y>=0)?'+':'-',(a.y>=0)?a.y:fabs(a.y),150);
}
int main()
{
vector a = initVector(3,pi/6);
vector b = initVector(5,2*pi/3);
printf("\nVector a : ");
printVector(a);
printf("\n\nVector b : ");
printVector(b);
printf("\n\nSum of vectors a and b : ");
printVector(addVector(a,b));
printf("\n\nDifference of vectors a and b : ");
printVector(subtractVector(a,b));
printf("\n\nMultiplying vector a by 3 : ");
printVector(multiplyVector(a,3));
printf("\n\nDividing vector b by 2.5 : ");
printVector(divideVector(b,2.5));
return 0;
}

View file

@ -1,40 +0,0 @@
struct &Vector {
$x
$y
}
fp.initVector = ($x, $y) -> {
return &Vector(fn.double($x), fn.double($y))
}
fp.addVector = ($a, $b) -> {
return parser.op(&Vector($a::$x + $b::$x, $a::$y + $b::$y))
}
fp.subVector = ($a, $b) -> {
return parser.op(&Vector($a::$x - $b::$x, $a::$y - $b::$y))
}
fp.mulVector = ($vec, $scalar) -> {
return parser.op(&Vector($vec::$x * $scalar, $vec::$y * $scalar))
}
fp.divVector = ($vec, $scalar) -> {
return parser.op(&Vector($vec::$x / $scalar, $vec::$y / $scalar))
}
fp.printVector = ($vec) -> {
fn.println([parser.op($vec::$x), parser.op($vec::$y)])
}
$vec1 = fp.initVector(5, 7)
$vec2 = fp.initVector(2, 3)
fp.printVector($vec1)
fp.printVector($vec2)
fn.println()
fp.printVector(fp.addVector($vec1, $vec2))
fp.printVector(fp.subVector($vec1, $vec2))
fp.printVector(fp.mulVector($vec1, 11))
fp.printVector(fp.divVector($vec1, 2))

View file

@ -1,8 +0,0 @@
$V1 = New-Object System.Windows.Vector ( 2.5, 3.4 )
$V2 = New-Object System.Windows.Vector ( -6, 2 )
$V1
$V2
$V1 + $V2
$V1 - $V2
$V1 * 3
$V1 / 8

View file

@ -1,5 +1,5 @@
-- 28 Jul 2025
include Settings
-- 24 Aug 2025
include Setting
say 'VECTOR'
say version