ICode9

精准搜索请尝试: 精确搜索
  • Eigen矩阵除法2022-08-07 12:30:09

    看了网上很多帖子,很多都没有说Eigen如何做矩阵除法。我这里补充一下。其他运算一般都可以查到; 对于Matrix来说,我们需要先将其转换成数组,因为Eigen矩阵不能做除法(很烦)。 比如我们一个2x4的矩阵,除以1x4的矩阵,python是可以使用numpy实现的(其实也是用的数组形式)。 Eigen::Matrix<doub

  • 「学习笔记」矩阵乘法与矩阵快速幂2022-08-05 17:34:37

    「学习笔记」矩阵乘法与矩阵快速幂 点击查看目录 目录「学习笔记」矩阵乘法与矩阵快速幂矩阵乘算法代码矩阵快速幂算法用处代码(模板题)练习题斐波那契数列思路代码[SCOI2009] 迷路思路代码佳佳的 Fibonacci思路代码选拔队员(不知道教练从哪里找的)题意思路代码Tr A思路代码 为什

  • leetcode 240. Search a 2D Matrix II 搜索二维矩阵 II(中等)2022-08-05 12:33:32

    一、题目大意 标签:数组 https://leetcode.cn/problems/search-a-2d-matrix-ii 编写一个高效的算法来搜索 m x n 矩阵 matrix 中的一个目标值 target 。该矩阵具有以下特性: 每行的元素从左到右升序排列。 每列的元素从上到下升序排列。 示例 1: 输入:matrix = [[1,4,7,11,15],[

  • 22.NumPy Matrix矩阵库2022-08-02 17:34:51

    NumPy 提供了一个 矩阵库模块numpy.matlib,该模块中的函数返回的是一个 matrix 对象,而非 ndarray 对象。矩阵由 m 行 n 列(m*n)元素排列而成,矩阵中的元素可以是数字、符号或数学公式等。 matlib.empty() matlib.empty() 返回一个空矩阵,所以它的创建速度非常快。 numpy.matlib.empty(s

  • LeetCode 74 Search a 2D Matrix 二分2022-07-29 02:32:09

    Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer

  • leetcode.59. 螺旋矩阵 II2022-07-29 00:31:29

    给你一个正整数 n ,生成一个包含 1 到 n2 所有元素,且元素按顺时针顺序螺旋排列的 n x n 正方形矩阵 matrix 。   示例 1: 输入:n = 3输出:[[1,2,3],[8,9,4],[7,6,5]]示例 2: 输入:n = 1输出:[[1]]  提示: 1 <= n <= 20 来源:力扣(LeetCode)链接:https://leetcode.cn/problems/spiral-mat

  • Python实现dijkstra算法2022-07-28 22:02:43

    目录dijkstra算法一、 简介1、 概念二、 实现原理1、 动图演示2、 思路解析三、 代码实现1、 构建矩阵2、 算法实现 dijkstra算法 一、 简介 1、 概念 Dijkstra(迪杰斯特拉)算法是典型的单源最短路径算法,用于计算一个节点到其他所有节点的最短路径。主要特点是以起始点为中心向外

  • BZOJ1409 Password 题解2022-07-28 16:31:06

    \(\mathrm{Describe.}\) 一种新的密码被研发出来了。想使用密码,首先需要用种子 \(\rm p\) 生成加密序列。具体的: \(\rm E_i= p\ \ \ \ i=1,2\) \(\rm E_i=E_{i-1}\times E_{i-2}\ \ \ i>2\) 之后,每次给出两个数 \(\rm n,q\),输出加密后的数字 \(\rm d\)。具体的加密方法为: \(\rm d=

  • LeetCode面试题 01.08. 零矩阵2022-07-28 09:35:06

    https://leetcode.cn/problems/zero-matrix-lcci/ class Solution { public void setZeroes(int[][] matrix) { int M=matrix.length; //获取二维数组中一维数组的长度 int N=matrix[0].length; int[][] newMat=new int[M][N]; //把

  • LeetCode482022-07-28 09:00:56

    https://leetcode.cn/problems/rotate-image/ class Solution { public void rotate(int[][] matrix) { int len=matrix.length; int[][] newMat=new int[len][len]; for(int i=0;i<len;i++){ for(int j=0;j<len;j++){

  • NO54. 螺旋矩阵2022-07-27 15:32:52

    整体思路     ->对于螺旋矩阵的题目四点: 1.起始位置 2.移动边界 3.边界 4.结束条件-<介于本题分别是: 1.左上角(0,0) 2.→↓←↑,使用二维数组存储 3.当每行遍历结束后,需要向内部移动从而达到螺旋 4.所有位置被遍历到   class Solution: def spiralOrder(self, matrix

  • leetcode.48. 旋转图像2022-07-26 23:04:31

      给定一个 n × n 的二维矩阵 matrix 表示一个图像。请你将图像顺时针旋转 90 度。 你必须在 原地 旋转图像,这意味着你需要直接修改输入的二维矩阵。请不要 使用另一个矩阵来旋转图像。   示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[[7,4,1]

  • MPI学习笔记(二):矩阵相乘的两种实现方法2022-07-25 20:34:34

    mpi矩阵乘法(C=αAB+βC)         最近领导让把之前安装的软件lapack、blas里的dgemm运算提取出来独立作为一套程序,然后把这段程序改为并行的,并测试一下进程规模扩展到128时的并行效率。        我发现这个是dgemm.f文件,里面主要是对C=αAB+βC的实现,因此在此总结一下MPI的

  • 高斯消元解线性方程组2022-07-24 01:33:10

    初等行变换 矩阵的初等行变换是实现高斯消元的方法 初等行变换有三种 某一行所有数乘\(k(k ≠ 0)\) 交换某两行 将某一行加上另一行的若干倍 高斯消元 高斯消元有四种操作 找到绝对值最大的一行(为了代码的稳定性) 将该行移到最上面 将该行第一个数变为1 将最上面一行下

  • 2022-7-23 剑指offer-二维前缀和2022-07-23 14:00:35

    剑指 Offer II 013. 二维子矩阵的和 难度中等47收藏分享切换为英文接收动态反馈 给定一个二维矩阵 matrix,以下类型的多个请求: 计算其子矩形范围内元素的总和,该子矩阵的左上角为 (row1, col1) ,右下角为 (row2, col2) 。 实现 NumMatrix 类: NumMatrix(int[][] matr

  • 【HDOJ 5895】Mathematician QSC 矩阵快速幂+欧拉定理2022-07-23 00:33:36

    参考 https://blog.csdn.net/queuelovestack/article/details/52577212 题目链接 https://acm.hdu.edu.cn/showproblem.php?pid=5895 思路 用f(n-1)乘上f(n)=f(n-2)+2*f(n-1),再通过移项、累加后得 g[n]=f[n] * f[n+1]/2 那么就可以首先通过矩阵快速幂计算出g(n*y)的值 关于除以

  • LeetCode 73 Set Matrix Zeroes 思维2022-07-22 06:31:14

    Given an m x n integer matrix matrix, if an element is \(0\), set its entire row and column to \(0\)'s. You must do it in place. Solution 做法并不难,但如果考虑常数空间复杂度的限制,我们只需要记录所在的 \(row,col\) 即可 点击查看代码 class Solution { private:

  • R语言基本语法2022-07-21 10:36:17

    更新一下r语言语法,因为课上要用到。 1.1 变量名命名规则:   R 语言的有效的变量名称由字母,数字以及点号 . 或下划线 _ 组成。   变量名称以字母或点开头。    1.2 变量赋值与处理: # three naming methods var.1 = c(1,2,3,4) print(var.1) var.2 <- c("hello") print(var

  • 第三周周总结2022-07-19 02:32:07

    本周主要是矩阵计算的相关任务 一下是 源码 // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr> // Copyright (C) 2010,2012 Jitse Niesen <jitse@maths.leeds.a

  • 7.18 数论专题题解2022-07-18 11:35:34

    \(\text{Sol. Luogu1397}\) 矩阵游戏 \(\to\text{Link}\leftarrow\) 好题。 题意: \[\begin{aligned} F[1,1]&=1\\ F[i,j]&=a\times F[i][j-1]+b (j\neq 1)\\ F[i,1]&=c\times F[i-1][m]+d (i\neq 1)\\ \end{aligned}\]求 \(F[n][m]\mod 1,000,000,

  • Word Vectors/Attention - hands on after lecture2022-07-17 14:32:05

    1. Write the co-occurrence matrix {\rm X}X for this sentence, using a 4-word context window (i.e. two context words on either side of the central word).   2. Use torch.svd() to compute the singular value decompositon of this matrix {\rm X} = {\rm USV}^

  • LeetCode Longest Increasing Path in a Matrix 记忆化搜索+DP [Hard]2022-07-15 05:31:06

    Given an \(m \times n\) integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directions: left, right, up, or down. You may not move diagonally or move outside the boundary (i.e., wrap-

  • 花式索引原理浅析2022-07-13 10:34:13

    假设我有如下三维tensor: matrix = torch.tensor([ [ [1,2,3], [4,5,6] ], [ [2,3,4], [5,6,7] ] ]) 索引方法为: matrix[ [ [0], [1] ], [ [0,1], [1,1] ], [ [2

  • 原地翻转或旋转矩阵2022-07-11 17:36:17

    idx, halfLen := len(matrix)-1, len(matrix) / 2 // 记录最后一个元素的下标和边长的一半 // 按对角线反转矩阵 for i := range matrix { for j := 0; j < i; j++ { matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j] } } // 按竖中轴线反转矩阵 for

  • I. Latitude Compressor 题解 - 2022 Hubei Provincial Collegiate Programming Contest2022-07-10 19:32:28

    传送门 赛时基本对了,结果被我推的错误数值表 hack 了队友,并且由于对多项式的操作不熟,导致最后一步一直没想出来 【大意】 给定 \(n, m\) ,求集合 \(\left\{ q | \left(\begin{matrix}1&2&3&\cdots&n\\p_1&p_2&p_3&\cdots&p_n\end{matrix}\right) ^ m = \left(\begin{matrix}1&2&

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有