Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 183 additions & 0 deletions .auto-claude-security.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"base_commands": [
".",
"[",
"[[",
"ag",
"awk",
"basename",
"bash",
"bc",
"break",
"cat",
"cd",
"chmod",
"clear",
"cmp",
"column",
"comm",
"command",
"continue",
"cp",
"curl",
"cut",
"date",
"df",
"diff",
"dig",
"dirname",
"du",
"echo",
"egrep",
"env",
"eval",
"exec",
"exit",
"expand",
"export",
"expr",
"false",
"fd",
"fgrep",
"file",
"find",
"fmt",
"fold",
"gawk",
"gh",
"git",
"grep",
"gunzip",
"gzip",
"head",
"help",
"host",
"iconv",
"id",
"jobs",
"join",
"jq",
"kill",
"killall",
"less",
"let",
"ln",
"ls",
"lsof",
"man",
"mkdir",
"mktemp",
"more",
"mv",
"nl",
"paste",
"pgrep",
"ping",
"pkill",
"popd",
"printenv",
"printf",
"ps",
"pushd",
"pwd",
"read",
"readlink",
"realpath",
"reset",
"return",
"rev",
"rg",
"rm",
"rmdir",
"sed",
"seq",
"set",
"sh",
"shuf",
"sleep",
"sort",
"source",
"split",
"stat",
"tail",
"tar",
"tee",
"test",
"time",
"timeout",
"touch",
"tr",
"tree",
"true",
"type",
"uname",
"unexpand",
"uniq",
"unset",
"unzip",
"watch",
"wc",
"wget",
"whereis",
"which",
"whoami",
"xargs",
"yes",
"yq",
"zip",
"zsh"
],
"stack_commands": [
"composer",
"ipython",
"jupyter",
"node",
"notebook",
"npm",
"npx",
"pdb",
"php",
"phpunit",
"pip",
"pip3",
"pipx",
"pudb",
"python",
"python3"
],
"script_commands": [
"./parallel.sh"
],
"custom_commands": [],
"detected_stack": {
"languages": [
"python",
"javascript",
"php"
],
"package_managers": [
"composer"
],
"frameworks": [
"phpunit"
],
"databases": [],
"infrastructure": [],
"cloud_providers": [],
"code_quality_tools": [],
"version_managers": []
},
"custom_scripts": {
"npm_scripts": [],
"make_targets": [],
"poetry_scripts": [],
"cargo_aliases": [],
"shell_scripts": [
"parallel.sh"
]
},
"project_dir": "/home/jordan/Projects/Fermat",
"created_at": "2026-01-17T02:59:58.884479",
"project_hash": "ff04866add36ffa1116480549ed508fe",
"inherited_from": "/home/jordan/Projects/Fermat"
}
25 changes: 25 additions & 0 deletions .auto-claude-status
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"active": true,
"spec": "001-matrix-minors-and-cofactors",
"state": "building",
"subtasks": {
"completed": 6,
"total": 7,
"in_progress": 1,
"failed": 0
},
"phase": {
"current": "Add Comprehensive Tests",
"id": null,
"total": 3
},
"workers": {
"active": 0,
"max": 1
},
"session": {
"number": 1,
"started_at": "2026-01-17T17:25:02.226019"
},
"last_update": "2026-01-17T17:25:02.286953"
}
39 changes: 39 additions & 0 deletions .claude_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"sandbox": {
"enabled": true,
"autoAllowBashIfSandboxed": true
},
"permissions": {
"defaultMode": "acceptEdits",
"allow": [
"Read(./**)",
"Write(./**)",
"Edit(./**)",
"Glob(./**)",
"Grep(./**)",
"Read(/home/jordan/Projects/Fermat/.auto-claude/worktrees/tasks/001-matrix-minors-and-cofactors/**)",
"Write(/home/jordan/Projects/Fermat/.auto-claude/worktrees/tasks/001-matrix-minors-and-cofactors/**)",
"Edit(/home/jordan/Projects/Fermat/.auto-claude/worktrees/tasks/001-matrix-minors-and-cofactors/**)",
"Glob(/home/jordan/Projects/Fermat/.auto-claude/worktrees/tasks/001-matrix-minors-and-cofactors/**)",
"Grep(/home/jordan/Projects/Fermat/.auto-claude/worktrees/tasks/001-matrix-minors-and-cofactors/**)",
"Read(/home/jordan/Projects/Fermat/.auto-claude/worktrees/tasks/001-matrix-minors-and-cofactors/.auto-claude/specs/001-matrix-minors-and-cofactors/**)",
"Write(/home/jordan/Projects/Fermat/.auto-claude/worktrees/tasks/001-matrix-minors-and-cofactors/.auto-claude/specs/001-matrix-minors-and-cofactors/**)",
"Edit(/home/jordan/Projects/Fermat/.auto-claude/worktrees/tasks/001-matrix-minors-and-cofactors/.auto-claude/specs/001-matrix-minors-and-cofactors/**)",
"Read(/home/jordan/Projects/Fermat/.auto-claude/**)",
"Write(/home/jordan/Projects/Fermat/.auto-claude/**)",
"Edit(/home/jordan/Projects/Fermat/.auto-claude/**)",
"Glob(/home/jordan/Projects/Fermat/.auto-claude/**)",
"Grep(/home/jordan/Projects/Fermat/.auto-claude/**)",
"Bash(*)",
"WebFetch(*)",
"WebSearch(*)",
"mcp__context7__resolve-library-id(*)",
"mcp__context7__get-library-docs(*)",
"mcp__graphiti-memory__search_nodes(*)",
"mcp__graphiti-memory__search_facts(*)",
"mcp__graphiti-memory__add_episode(*)",
"mcp__graphiti-memory__get_episodes(*)",
"mcp__graphiti-memory__get_entity_edge(*)"
]
}
}
23 changes: 13 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
.idea
vendor/
composer.lock
build
.phpunit.result.cache
site
tools/
.php-cs-fixer.cache
.phive/
phive.phar.asc
.idea
vendor/
composer.lock
build
.phpunit.result.cache
site
tools/
.php-cs-fixer.cache
.phive/
phive.phar.asc

# Auto Claude data directory
.auto-claude/
37 changes: 33 additions & 4 deletions src/Samsara/Fermat/LinearAlgebra/Types/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,21 @@ public function getDeterminant(): ImmutableDecimal
);
}

if ($this->numRows > 2) {
if ($this->numRows === 0) {
// The determinant of a 0x0 matrix is defined as 1 by convention
$determinant = Numbers::makeOne();
} elseif ($this->numRows === 1) {
$determinant = $this->rows[0]->get(0);
} elseif ($this->numRows === 2) {
$determinant = $this->rows[0]->get(0)->multiply($this->rows[1]->get(1))->subtract($this->rows[1]->get(0)->multiply($this->rows[0]->get(1)));
} else {
$determinant = Numbers::makeZero();

foreach ($this->rows[0]->toArray() as $key => $value) {
$childMatrix = $this->childMatrix(0, $key);

$determinant = $determinant->add($value->multiply($childMatrix->getDeterminant())->multiply(SequenceProvider::nthPowerNegativeOne($key)));
}
} else {
$determinant = $this->rows[0]->get(0)->multiply($this->rows[1]->get(1))->subtract($this->rows[1]->get(0)->multiply($this->rows[0]->get(1)));
}

return $determinant;
Expand All @@ -84,7 +89,6 @@ public function getInverseMatrix(): static
$determinant = $this->getDeterminant();
$inverseDeterminant = new ImmutableFraction(Numbers::makeOne(), $determinant);

// TODO: Implement minors & cofactors method https://www.mathsisfun.com/algebra/matrix-inverse-minors-cofactors-adjugate.html
if ($this->getRowCount() > 2) {
$minors = $this->getMatrixOfMinors();
$cofactors = $minors->applyAlternatingSigns();
Expand Down Expand Up @@ -114,6 +118,31 @@ public function getMatrixOfMinors(): static
return $this->mapFuction($fn);
}

/**
* Returns a new collection that contains the matrix of minors for each element in the current collection.
*
* This is an alias for getMatrixOfMinors().
*
* @return static A new collection containing the matrix of minors.
*/
public function minors(): static
{
return $this->getMatrixOfMinors();
}

/**
* Returns a new matrix containing the cofactors of each element in the current matrix.
*
* The matrix of cofactors is obtained by taking the matrix of minors and applying alternating signs
* based on position. The sign pattern follows a checkerboard pattern starting with + at position (0,0).
*
* @return static A new matrix containing the cofactors.
*/
public function cofactors(): static
{
return $this->getMatrixOfMinors()->applyAlternatingSigns();
}

/**
* Adds a MatrixInterface object to the current matrix and returns a new matrix with the sum.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ public function getAdjoint(): static
}

/**
* Returns the adjugate matrix (also known as classical adjoint).
*
* The adjugate is the transpose of the cofactor matrix.
* This is different from getAdjoint() which is just the transpose.
*
* @return static
*/
public function getAdjugate(): static
{
return $this->getAdjoint();
return $this->cofactors()->getAdjoint();
}

/**
Expand Down
Loading
Loading