From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by sourceware.org (Postfix) with ESMTPS id BA26D384DED3 for ; Wed, 29 Nov 2023 20:04:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA26D384DED3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BA26D384DED3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::f2f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701288282; cv=none; b=CT4ZyaiJG5Vr2cmP1xCiDj7p1LQP7UFRv3LHTJgyPxTQQQoqF59aq0aBnxCrji/7Moe9VY5EnIsTSMecT+ye+PJs2N/weXmd38FSqYxHGfzViKL7Hue9n+iONcZxx8yZgMuSxLCCtqxnvZjxIpbeFQuaMDxfU6fqEIiP1IGl/HY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701288282; c=relaxed/simple; bh=bztfpLxODfo3wWIUaW+61t+rdKFxqwD143Lkv7LN/dI=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=JmhP//Dp8hKYkUK0ZxqZ6lYtn0WhNX0h6cNDrdAt3/E+yGOEdvXiexrEphDhGsJ+fpt4EnfBbSTgZikcVguCo2lx1MYPnVYqT1KZGqaWbLJ9qKUr5iZ6BA7gUm3M+1lWBxFsYFcDoNjgQG1y0I0qijbkYS4LP/gO/wOlv7HQVxU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qv1-xf2f.google.com with SMTP id 6a1803df08f44-67a35b68c34so862286d6.3 for ; Wed, 29 Nov 2023 12:04:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701288279; x=1701893079; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=Ugv+WQ0zjA5DIIxsiHscMDmYLdOdvfevEQIq8kCbLNk=; b=OtAq5hh5dLpYi7Xtse3UBKCuk8x+TV0Cxe7IlMNYbhgk+4hrgZAt5iB6CWLOhpqRE2 RP034JuZjCssGv63hoKglkfbXQ2ws8qTNZ8+a7gIXjWlqwygNy/d/BEWTBTIjgfQ/OQl 7CF4jANhyR6qcIZ1w8OvO/tZN0UXBDD4nkBzD3BbdkbaZ9HoDImOZMmoiDU+qbHPu7Qg t5j79ekSeG29MS7SmHPE2xGmwX0jxAdS/j4clsRUeNqEWzXjP4EJnXgDATQhoPHr1x5S a8PbSgcHEIyWRvcTEyQr/AN9dvD0jcvVlJLsaJjozt2th+fXR44g2DDD3SLHfWVIuMyW 3nUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701288279; x=1701893079; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Ugv+WQ0zjA5DIIxsiHscMDmYLdOdvfevEQIq8kCbLNk=; b=SeL2icko+2ZaJvikVDc4UXL/hT2abUWIwjQCYbip2bfYDJz145J/IiydR59U2GgE7m L6ZYerPODgAxYCoDh/FTBM9/0+P1TJLGwTtnUNaavYvoDh62CNMTadEFsq1T5zd/RpPP WlrLyuZxlyUFF7dXc8QbW6Wt667Vb26ezza1k0BiFIyXWDPWs3y+DIT1ETLm3nakTIq6 f5VecdDRLN5U9q3X0pbiin2Ay542rl2YLPQ/CcotfEIJj5aAsCmuFE/Xl4rAvt46lqYR WQ/gC/OLOrT4dGtxcdFVnhPxYXthrGuhjIN6AZO1WEjwxJ9o/RXKAyi/nLGhVnH8gg19 TVlA== X-Gm-Message-State: AOJu0YxZc8Uf3jzyFJSEg5rjT8o29GCc1GtqV7jvCc2RaWUMKo8N4F8o sGSi3Asta0QLR3dEwTxTXrwKXpc/YdjGqniZGCM= X-Google-Smtp-Source: AGHT+IEXwbSOF3oaVfdw/8wMhcpxZNPybtDTTlL7uIBORGGuz9jhWC8ozUFwK0w/48xueO7dr8KsqsTS0W3W4MArF2Y= X-Received: by 2002:ad4:5152:0:b0:67a:1f78:5dc with SMTP id g18-20020ad45152000000b0067a1f7805dcmr16553561qvq.30.1701288278854; Wed, 29 Nov 2023 12:04:38 -0800 (PST) MIME-Version: 1.0 From: Duke Abbaddon Date: Wed, 29 Nov 2023 20:04:27 +0000 Message-ID: Subject: Positive Views & potential : Compression, Dictionary Sort & Same Size Copy Match & Unite Same with location in 2D Matrix #JS #C #Python RS 2023 https://is.gd/CJS_DictionarySort To: amd.gcc@amd.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Compression, Dictionary Sort & Same Size Copy Match & Unite Same with location in 2D Matrix #JS #C #Python RS 2023 https://is.gd/CJS_DictionarySort The code appears complex; But there you go! In assembler it may be 15KB to 64KB; I am not entirely sure, However the objective is for ZSTD, GZIP, Brotli & Codecs such as DSC, The compression rate improves & the quality of the compression also! Depending on the encryption type; You may also improve the complexity by deviating from commons or by compressing better first. Sorting memory load arrays so they align neatly into a block; Accounting Dates into Same ID & Order; Ordered identical ID; Taxing blocks, Accounting for block loads & saves so that blocks in the same locations & size are loaded & stored neatly.. Aligned minimal block formations save space on block systems such as NTFS & EFS & Advanced Format with Extended Directories such as on the Amiga & Mac These & many more uses depending on speed & parallel code ordering & identification Unification, Depending entirely on block size & efficiency of sort & collation grouping. RS Bluetooth dongle LE Protocol https://drive.google.com/file/d/17csRnAfdceZiTSnQZvhaLqLSwL__zsIG/view?usp=sharing https://science.n-helix.com/2022/09/ovccans.html https://science.n-helix.com/2022/03/ice-ssrtp.html https://science.n-helix.com/2022/04/vecsr.html https://science.n-helix.com/2022/02/interrupt-entropy.html Rupert S code for sorting and matching a 2D matrix can vary depending on the specific assembler architecture and compiler being used. Here's a general outline of the steps involved: Load and Initialize Data: Load the 2D matrix into memory, keeping track of its dimensions (rows and columns). Initialize an auxiliary array to store the first and last occurrences of each value in each row. Initialize an empty array to store the combined matrix. Initialize a counter for the number of same rows found. Sort Each Row: Iterate through each row of the matrix. For each row, use a sorting algorithm, such as bubble sort or insertion sort, to sort the elements in ascending order. Find First and Last Occurrences: Iterate through each row of the sorted matrix. For each element in the row, scan the remaining elements in the row to find its first and last occurrences. Store the first and last occurrences in the corresponding auxiliary array. Identify Same Rows: Iterate through each row of the matrix. For each row, check if all elements have the same first and last occurrences as the corresponding elements in the previous row. If all elements match, mark the row as a "same row" and increment the counter. Combine Same Rows: Allocate memory for the combined matrix based on the number of same rows found. Iterate through the same rows, copying the elements of each same row into the corresponding row of the combined matrix. Sort Combined Matrix: Sort the combined matrix using a sorting algorithm. Update Output Arrays: Store the sorted combined matrix in the provided output array. Store the indices of the same rows in the provided output array. #JS function sortAndMatch(matrix) { // Sort each row of the matrix const sortedMatrix = matrix.map((row) => row.sort((a, b) => a - b)); // Find the first occurrence of each value in each row const firstOccurrences = []; for (let i = 0; i < matrix.length; i++) { const row = matrix[i]; const firstOccurrencesRow = {}; for (let j = 0; j < row.length; j++) { const value = row[j]; if (!firstOccurrencesRow.hasOwnProperty(value)) { firstOccurrencesRow[value] = j; } } firstOccurrences.push(firstOccurrencesRow); } // Find the last occurrence of each value in each row const lastOccurrences = []; for (let i = 0; i < matrix.length; i++) { const row = matrix[i]; const lastOccurrencesRow = {}; for (let j = row.length - 1; j >= 0; j--) { const value = row[j]; if (!lastOccurrencesRow.hasOwnProperty(value)) { lastOccurrencesRow[value] = j; } } lastOccurrences.push(lastOccurrencesRow); } // Find the first and last occurrences of each value in the matrix const firstOccurrencesAll = {}; for (const row of firstOccurrences) { for (const value in row) { if (!firstOccurrencesAll.hasOwnProperty(value) || firstOccurrencesAll[value] > row[value]) { firstOccurrencesAll[value] = row[value]; } } } const lastOccurrencesAll = {}; for (const row of lastOccurrences) { for (const value in row) { if (!lastOccurrencesAll.hasOwnProperty(value) || lastOccurrencesAll[value] < row[value]) { lastOccurrencesAll[value] = row[value]; } } } // Find the rows that contain the same values const sameRows = []; for (let i = 0; i < matrix.length; i++) { const row = matrix[i]; let same = true; for (let j = 0; j < row.length; j++) { const value = row[j]; const firstOccurrence = firstOccurrencesAll[value]; const lastOccurrence = lastOccurrencesAll[value]; if (firstOccurrence !== lastOccurrence || firstOccurrences[i][value] !== firstOccurrence || lastOccurrences[i][value] !== lastOccurrence) { same = false; break; } } if (same) { sameRows.push(i); } } // Combine the same rows into a single row const combinedMatrix = []; for (const row of sameRows) { combinedMatrix.push(matrix[row]); } // Sort the combined matrix const sortedCombinedMatrix = combinedMatrix.map((row) => row.sort((a, b) => a - b)); return { sortedCombinedMatrix, sameRows }; } const matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]; const result = sortAndMatch(matrix); console.log(result.sortedCombinedMatrix); console.log(result.sameRows); #C #include #include typedef struct { int value; int firstOccurrence; int lastOccurrence; } ValueInfo; void sortAndMatch(int matrix[][3], int rows, int cols, int** sortedCombinedMatrix, int* sameRows, int* sameRowsCount) { // Allocate memory for the first and last occurrences of each value in each row ValueInfo** firstOccurrences = (ValueInfo**)malloc(sizeof(ValueInfo*) * rows); for (int i = 0; i < rows; i++) { firstOccurrences[i] = (ValueInfo*)malloc(sizeof(ValueInfo) * cols); } ValueInfo** lastOccurrences = (ValueInfo**)malloc(sizeof(ValueInfo*) * rows); for (int i = 0; i < rows; i++) { lastOccurrences[i] = (ValueInfo*)malloc(sizeof(ValueInfo) * cols); } // Find the first and last occurrences of each value in each row for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { int value = matrix[i][j]; bool foundFirst = false; bool foundLast = false; for (int k = 0; k < cols; k++) { if (matrix[i][k] == value && !foundFirst) { firstOccurrences[i][j].value = value; firstOccurrences[i][j].firstOccurrence = k; foundFirst = true; } if (matrix[i][k] == value && !foundLast) { lastOccurrences[i][j].value = value; lastOccurrences[i][j].lastOccurrence = k; foundLast = true; } } } } // Find the first and last occurrences of each value in the matrix ValueInfo* firstOccurrencesAll = (ValueInfo*)malloc(sizeof(ValueInfo) * cols); for (int i = 0; i < cols; i++) { firstOccurrencesAll[i].value = -1; firstOccurrencesAll[i].firstOccurrence = -1; firstOccurrencesAll[i].lastOccurrence = -1; } ValueInfo* lastOccurrencesAll = (ValueInfo*)malloc(sizeof(ValueInfo) * cols); for (int i = 0; i < cols; i++) { lastOccurrencesAll[i]. #Python import numpy as np def sort_and_match(matrix): # Sort each row of the matrix sorted_matrix = np.sort(matrix, axis=1) # Find the first occurrence of each value in each row first_occurrences = np.zeros_like(matrix) for i in range(matrix.shape[0]): for j in range(matrix.shape[1]): if matrix[i, j] not in first_occurrences[i, :j]: first_occurrences[i, j] = j # Find the last occurrence of each value in each row last_occurrences = np.zeros_like(matrix) for i in range(matrix.shape[0]): for j in range(matrix.shape[1]-1, -1, -1): if matrix[i, j] not in last_occurrences[i, j+1:]: last_occurrences[i, j] = j # Find the first and last occurrences of each value in the matrix first_occurrences_all = np.min(first_occurrences, axis=0) last_occurrences_all = np.max(last_occurrences, axis=0) # Find the rows that contain the same values same_rows = [] for i in range(matrix.shape[0]): if np.all(first_occurrences[i, :] == last_occurrences[i, :]): same_rows.append(i) # Combine the same rows into a single row combined_matrix = np.zeros((len(same_rows), matrix.shape[1])) for i, row in enumerate(same_rows): combined_matrix[i, :] = matrix[row, :] # Sort the combined matrix sorted_combined_matrix = np.sort(combined_matrix, axis=1) return sorted_combined_matrix, same_rows matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) sorted_combined_matrix, same_rows = sort_and_match(matrix) print(sorted_combined_matrix) print(same_rows)