Ada - 提出可访问性检查

2023-12-27

我从Github下载了这个程序:https://github.com/raph-amiard/ada-synth-lib https://github.com/raph-amiard/ada-synth-lib

我尝试了第一个例子,但遇到了一个例外。如果有人能够让我深入了解这是为什么,我将不胜感激。我已经被这个问题困扰了很长时间,而且我真的很渴望让它发挥作用。

我收到的错误是:raised PROGRAM_ERROR : waves.adb:110 accessibility check failed

这是主要文件:

with Waves; use Waves;
with Write_To_Stdout; 



procedure Main is



   Sine_Gen : constant access Sine_Generator := Create_Sine (Fixed (440.0));

begin


  Write_To_Stdout (Sine_Gen);


end Main;

这是waves.adb 文件

with Effects; use Effects;
with Interfaces; use Interfaces;

package body Waves is

   function Mod_To_Int (A : Unsigned_32) return Integer_32;

   -------------------
   -- Update_Period --
   -------------------

   procedure Update_Period
     (Self : in out Wave_Generator'Class; Buffer : in out Period_Buffer)
   is
   begin
      Self.Frequency_Provider.Next_Samples (Buffer);
      for I in Buffer'Range loop
         Buffer (I) :=
           Utils.Period_In_Samples
             (Frequency (Buffer (I)));
      end loop;
   end Update_Period;

   ------------
   -- Create --
   ------------

   function Create_Saw
     (Freq_Provider : Generator_Access) return access Saw_Generator
   is
   begin
      return new Saw_Generator'(Frequency_Provider => Freq_Provider,
                                Current => -1.0, others => <>);
   end Create_Saw;

   -----------------
   -- Next_Sample --
   -----------------

   overriding procedure Next_Samples
     (Self : in out Saw_Generator; Buffer : in out Generator_Buffer)
   is
      P_Buffer : Period_Buffer;
   begin
      Update_Period (Self, P_Buffer);
      for I in Buffer'Range loop
         Self.Step := 2.0 / Float (P_Buffer (I));
         Self.Current := Self.Current + Sample (Self.Step);
         if Self.Current > 1.0 then
            Self.Current := Self.Current - 2.0;
         end if;
         Buffer (I) := Self.Current;
      end loop;
   end Next_Samples;

   ------------
   -- Create --
   ------------

   function Create_Square
     (Freq_Provider : access Generator'Class) return access Square_Generator is
   begin
      return new Square_Generator'(Frequency_Provider =>
                                     Generator_Access (Freq_Provider),
                                   Is_High => True,
                                   Current_Sample => 0,
                                   others => <>);
   end Create_Square;

   -----------------
   -- Next_Sample --
   -----------------

   overriding procedure Next_Samples
     (Self : in out Square_Generator; Buffer : in out Generator_Buffer)
   is
      P_Buffer : Period_Buffer;
   begin
      Update_Period (Self, P_Buffer);
      for I in Buffer'Range loop
         Self.Current_Sample := Self.Current_Sample + 1;
         declare
            A : constant Period := Period (Self.Current_Sample)
              / P_Buffer (I);
         begin
            if A >= 1.0 then
               Self.Current_Sample := 0;
               Buffer (I) := 1.0;
            end if;
            Buffer (I) := (if A >= 0.5 then 1.0 else -1.0);
         end;
      end loop;
   end Next_Samples;

   ------------
   -- Create --
   ------------

   function Create_Sine
     (Freq_Provider : access Generator'Class) return access Sine_Generator
   is
      Ret : constant access Sine_Generator :=
        new Sine_Generator'(Frequency_Provider =>
                              Generator_Access (Freq_Provider),
                            Current_Sample => 0,
                            Current_P => 0.0,
                            others => <>);
   begin
      Ret.Current_P := 0.0;
      return Ret;
   end Create_Sine;

   -----------------
   -- Next_Sample --
   -----------------

   overriding procedure Next_Samples
     (Self : in out Sine_Generator; Buffer : in out Generator_Buffer)
   is
      P_Buffer : Period_Buffer;
   begin
      Update_Period (Self, P_Buffer);
      for I in Buffer'Range loop
         Self.Current_Sample := Self.Current_Sample + 1;
         if Period (Self.Current_Sample) >= Self.Current_P then
            Self.Current_P := P_Buffer (I) * 2.0;
            Self.Current_Sample := 0;
         end if;
         Buffer (I) :=
           Sample
             (Sin
                (Float (Self.Current_Sample)
                 / Float (Self.Current_P) * Pi * 2.0));
      end loop;
   end Next_Samples;

   ------------
   -- Create --
   ------------

   function Create_Chain
     (Gen : access Generator'Class;
      Sig_Procs : Signal_Processors
        := No_Signal_Processors) return access Chain
   is
      Ret : constant access Chain :=
        new Chain'(Gen => Generator_Access (Gen), others => <>);
   begin
      for P of Sig_Procs loop
         Ret.Add_Processor (P);
      end loop;
      return Ret;
   end Create_Chain;

   -------------------
   -- Add_Processor --
   -------------------

   procedure Add_Processor
     (Self : in out Chain; P : Signal_Processor_Access) is
   begin
      Self.Processors (Self.Nb_Processors) := P;
      Self.Nb_Processors := Self.Nb_Processors + 1;
   end Add_Processor;

   -----------------
   -- Next_Sample --
   -----------------

   overriding procedure Next_Samples
     (Self : in out Chain; Buffer : in out Generator_Buffer)
   is
      S : Sample;
   begin
      Self.Gen.Next_Samples (Buffer);
      for J in Buffer'Range loop
         S := Buffer (J);
         for I in 0 .. Self.Nb_Processors - 1 loop
            S := Self.Processors (I).Process (S);
         end loop;
         Buffer (J) := S;
      end loop;
   end Next_Samples;

   ---------
   -- LFO --
   ---------

   function LFO (Freq : Frequency; Amplitude : Float) return Generator_Access
   is
      Sin : constant Generator_Access := Create_Sine (Fixed (Freq));
   begin
      return new Attenuator'
        (Level => Amplitude,
         Source => new Transposer'(Source => Sin, others => <>), others => <>);
   end LFO;

   ------------
   -- Create --
   ------------

   function Create_ADSR
     (Attack, Decay, Release : Millisecond; Sustain : Scale;
      Source : access Note_Generator'Class := null) return access ADSR
   is
   begin
      return new ADSR'
        (State     => Off,
         Source    => Source,
         Attack    => Msec_To_Period (Attack),
         Decay     => Msec_To_Period (Decay),
         Release   => Msec_To_Period (Release),
         Sustain   => Sustain,
         Current_P => 0, others => <>);
   end Create_ADSR;

   -----------------
   -- Next_Sample --
   -----------------

   overriding procedure Next_Samples
     (Self : in out ADSR; Buffer : in out Generator_Buffer)
   is
      Ret : Sample;
   begin
      for I in Buffer'Range loop
         case Self.Source.Buffer (I).Kind is
         when On =>
            Self.Current_P := 0;
            Self.State := Running;
         when Off =>
            Self.State := Release;
            Self.Cur_Sustain := Scale (Self.Memo_Sample);
            Self.Current_P := 0;
         when No_Signal => null;
         end case;

         Self.Current_P := Self.Current_P + 1;

         case Self.State is
         when Running =>
            if Self.Current_P in 0 .. Self.Attack then
               Ret := Exp8_Transfer
                 (Sample (Self.Current_P) / Sample (Self.Attack));
            elsif
              Self.Current_P in Self.Attack + 1 .. Self.Attack + Self.Decay
            then
               Ret :=
                 Exp8_Transfer
                   (Float (Self.Decay + Self.Attack - Self.Current_P)
                    / Float (Self.Decay));

               Ret := Ret
               * Sample (1.0 - Self.Sustain)
                 + Sample (Self.Sustain);
            else
               Ret := Sample (Self.Sustain);
            end if;
            Self.Memo_Sample := Ret;
         when Release =>
            if Self.Current_P in 0 .. Self.Release then
               Ret :=
                 Exp8_Transfer
                   (Sample (Self.Release - Self.Current_P)
                    / Sample (Self.Release))
                 * Sample (Self.Cur_Sustain);
            else
               Self.State := Off;
               Ret := 0.0;
            end if;
         when Off  => Ret := 0.0;
         end case;

         Buffer (I) := Ret;
      end loop;
   end Next_Samples;

   ----------------------
   -- Next_Sample --
   ----------------------

   overriding procedure Next_Samples
     (Self : in out Pitch_Gen; Buffer : in out Generator_Buffer)
   is
      Ret : Sample;
   begin
      if Self.Proc /= null then
         Self.Proc.Next_Samples (Buffer);
      end if;

      for I in Buffer'Range loop
         case Self.Source.Buffer (I).Kind is
         when On =>
            Self.Current_Note := Self.Source.Buffer (I).Note;
            Self.Current_Freq :=
              Note_To_Freq (Self.Current_Note, Self.Relative_Pitch);
         when others => null;
         end case;

         Ret := Sample (Self.Current_Freq);

         if Self.Proc /= null then
            Ret := Ret + Buffer (I);
         end if;

         Buffer (I) := Ret;
      end loop;
   end Next_Samples;

   ------------------
   -- Create_Noise --
   ------------------

   function Create_Noise return access Noise_Generator
   is
      N : constant access Noise_Generator := new Noise_Generator;
   begin
      return N;
   end Create_Noise;

   F_Level : constant Sample := 2.0 / Sample (16#FFFFFFFF#);
   G_X1 : Unsigned_32 := 16#67452301#;
   G_X2 : Unsigned_32 := 16#EFCDAB89#;
   Z : constant := 2 ** 31;

   ----------------
   -- Mod_To_Int --
   ----------------

   function Mod_To_Int (A : Unsigned_32) return Integer_32 is
      Res : Integer_32;
   begin
      if A < Z then
         return Integer_32 (A);
      else
         Res := Integer_32 (A - Z);
         Res := Res - (Z - 1) - 1;
         return Res;
      end if;
   end Mod_To_Int;

   ------------------
   -- Next_Samples --
   ------------------

   overriding procedure Next_Samples
     (Self : in out Noise_Generator; Buffer : in out Generator_Buffer)
   is
      pragma Unreferenced (Self);
   begin
      for I in Buffer'Range loop
         G_X1 := G_X1 xor G_X2;
         Buffer (I) := Sample (Mod_To_Int (G_X2)) * F_Level;
         G_X2 := G_X2 + G_X1;
      end loop;
   end Next_Samples;

   ------------------
   -- Next_Samples --
   ------------------

   overriding procedure Next_Samples
     (Self : in out Fixed_Gen; Buffer : in out Generator_Buffer) is
   begin

      if Self.Proc /= null then
         Self.Proc.Next_Samples (Buffer);
         for I in Buffer'Range loop
            Buffer (I) := Self.Val + Buffer (I);
         end loop;
      else
         for I in Buffer'Range loop
            Buffer (I) := Self.Val;
         end loop;
      end if;
   end Next_Samples;

   -----------
   -- Reset --
   -----------

   overriding procedure Reset (Self : in out ADSR) is
   begin
      Base_Reset (Self);
      Reset_Not_Null (Self.Source);
      Self.Memo_Sample := 0.0;
   end Reset;

   -----------
   -- Reset --
   -----------

   overriding procedure Reset (Self : in out Saw_Generator) is
   begin
      Base_Reset (Self);
      Reset_Not_Null (Self.Frequency_Provider);
      Self.Current := -1.0;
   end Reset;

   -----------
   -- Reset --
   -----------

   overriding procedure Reset (Self : in out Square_Generator) is
   begin
      Base_Reset (Self);
      Reset_Not_Null (Self.Frequency_Provider);
      Self.Current_Sample := 0;
      Self.Is_High := True;


   end Reset;

   -----------
   -- Reset --
   -----------

   overriding procedure Reset (Self : in out Sine_Generator) is
   begin
      Base_Reset (Self);
      Reset_Not_Null (Self.Frequency_Provider);
      Self.Current_Sample := 0;
   end Reset;

   -----------
   -- Reset --
   -----------

   overriding procedure Reset (Self : in out Noise_Generator) is
   begin
      Base_Reset (Self);
      Reset_Not_Null (Self.Frequency_Provider);
   end Reset;

   -----------
   -- Reset --
   -----------

   overriding procedure Reset (Self : in out Pitch_Gen) is
   begin
      Base_Reset (Self);
      Reset_Not_Null (Self.Source);
      Reset_Not_Null (Self.Proc);
   end Reset;

   -----------
   -- Reset --
   -----------

   overriding procedure Reset (Self : in out Fixed_Gen) is
   begin
      Base_Reset (Self);
      Reset_Not_Null (Self.Proc);
   end Reset;

   -----------
   -- Reset --
   -----------

   overriding procedure Reset (Self : in out Chain) is
   begin
      Base_Reset (Self);
      Reset_Not_Null (Self.Gen);
   end Reset;

   -----------
   -- Fixed --
   -----------

   function Fixed
     (Freq        : Frequency;
      Modulator   : Generator_Access := null;
      Name        : String := "";
      Min         : Float := 0.0;
      Max         : Float := 5_000.0;
      Param_Scale : Param_Scale_T := Linear)
      return access Fixed_Gen
   is
   begin
      return new
        Fixed_Gen'
          (Val         => Sample (Freq),
           Proc        => Modulator,
           Name        => To_Unbounded_String (Name),
           Min         => Min,
           Max         => Max,
           Param_Scale => Param_Scale,
           others      => <>);
   end Fixed;

   ---------------
   -- Set_Value --
   ---------------

   overriding procedure Set_Value
     (Self : in out Fixed_Gen; I : Natural; Val : Float)
   is
      pragma Unreferenced (I);
   begin
      Self.Val := Sample (Val);
   end Set_Value;

   ---------------
   -- Set_Value --
   ---------------

   overriding procedure Set_Value
     (Self : in out ADSR; I : Natural; Val : Float)
   is
   begin
      case I is
         when 0 => Self.Attack := Sec_To_Period (Val);
         when 1 => Self.Decay :=  Sec_To_Period (Val);
         when 2 => Self.Sustain := Scale (Val);
         when 3 => Self.Release := Sec_To_Period (Val);
         when others => raise Constraint_Error;
      end case;
   end Set_Value;

end Waves;

最后,write_to_stdout.adb 文件

with Utils; use Utils;
with GNAT.OS_Lib;

procedure Write_To_Stdout (G : access Generator'Class)
is
   function Sample_To_Int16 is new Sample_To_Int (Short_Integer);
   Int_Smp : Short_Integer := 0;
   Ignore  : Integer;
   Buffer  : Generator_Buffer;
begin

   loop
      Next_Steps;
      G.Next_Samples (Buffer);

      for I in Buffer'Range loop
         Int_Smp := Sample_To_Int16 (Buffer (I));
         Ignore := GNAT.OS_Lib.Write
           (GNAT.OS_Lib.Standout, Int_Smp'Address, Int_Smp'Size / 8);
      end loop;

      exit when Sample_Nb > 10_000_000;
      Sample_Nb := Sample_Nb + Generator_Buffer_Length;
   end loop;

end Write_To_Stdout;

感谢您的阅读,非常感谢任何解决此问题的指导。

Cheers,

Lloyd


有问题的功能:

   function Create_Sine
     (Freq_Provider : access Generator'Class) return access Sine_Generator
   is
      Ret : constant access Sine_Generator :=
        new Sine_Generator'(Frequency_Provider =>
                              Generator_Access (Freq_Provider),
                            Current_Sample => 0,
                            Current_P => 0.0,
                            others => <>);
   begin
      Ret.Current_P := 0.0;
      return Ret;
   end Create_Sine;

创建一个新对象,由其本地范围内的访问类型访问并返回访问的副本。在这种情况下,它可能没问题,但也有可能出现类似的情况,即当函数返回时对象本身超出范围,留下悬空访问。

在这种情况下,它可能过于谨慎,因为对对象的唯一引用是返回的,但可访问性检查禁止整个类可能存在错误的构造。我说“可能”是因为理论上该对象可以由某些编译器分配在堆栈上,或者分配在本地拥有的存储池中,而不是“堆”中,以实现更可靠的对象生命周期管理。

有一个解决方案:在返回的对象中创建访问,而不是在立即丢弃的本地对象中。 Ada-2005 及更高版本提供了“扩展返回”结构来实现此目的。它看起来像:

   function Create_Sine
     (Freq_Provider : access Generator'Class) return access Sine_Generator
   is
   begin
      return Ret : constant access Sine_Generator :=
        new Sine_Generator'( Frequency_Provider =>
                              Generator_Access (Freq_Provider),
                            Current_Sample => 0,
                            Current_P => 0.0,
                            others => <>) 
        do
            -- initialisation actions here
            Ret.Current_P := 0.0;
        end return;
   end Create_Sine;

未测试!但既然你知道了它的名字,任何常用的来源都应该能让你保持清醒。

这里的caller拥有用新对象初始化的访问类型,因此不存在访问类型比被访问对象寿命更长的危险。

总的来说,这个问题可能有更好的答案。我刚刚谈到了最直接的问题,但更广泛的问题是,您是否需要这里的访问类型?在 Ada 中,答案通常(但并非总是)是否定的。在很多情况下,来自其他语言的程序员只是使用指针,而 Ada 中有更简单或更好的处理方法。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Ada - 提出可访问性检查 的相关文章

  • Ada 中的自定义“图像属性”?

    所以我有一件事 type Thing is new record elements end record 我有一个将其字符串化的函数 function ToString t Thing returns string 我希望能够告诉 Ada
  • 如何创建 ada lib.a 并链接到 C

    我正在尝试创建一个 ada 库并尝试了一些不同的东西 我尝试使用 makefile 编译项目并尝试从所有 o 文件创建一个库 这似乎没有按预期工作 然后我询问了 adacore 支持 他们向我指出了在 ada 和 c 项目中使用 gpr 文
  • Ada 中的派生类型和子类型

    有什么区别 首先 术语 它是 Ada 不是 ADA 它是以 Ada Lovelace 命名的 它不是一个缩写词 子类型与其基类型兼容 因此您可以将基类型的操作数与基类型的操作数混合 例如 subtype Week Days is Integ
  • 从 Ada 调用 scanf

    如何从 Ada 调用 scanf 也就是说 大概有一个适当的 pragma import 声明 但是声明会是什么样子呢 我感兴趣的是如何从 Ada 调用更难以驾驭的 C 函数 而不是如何解析字符串本身 所以我不是在寻找纯粹的 Ada 解决方
  • 在 GPS (Ada IDE) 中使用 glib.h 进行编译时出现问题

    我在尝试在 GPS 中编译 Ada 代码时遇到一些麻烦 当我将 GPS 放入包裹中时 它显示丢失 我尝试使用 apt get 安装 确实如此 但错误仍然存 在 接下来我能做什么 我在 x64 Ubuntu 12 04 上运行 GPS 这是我
  • Ada:包装概念[关闭]

    Closed 这个问题是基于意见的 目前不接受答案 这是我之前的帖子的后续内容 Ada 了解私有类型并了解包装 一个实现Rectangular类型是使用一种实现来制作的 即Rectangular Method 1此实现需要一个规范文件和一个
  • 是否可以声明具有无限上限的 Ada 范围?

    我想在 Ada 中声明记录类型的速度范围 下面的方法行不通 但是有没有办法让它工作呢 Speed in knots range 0 to unlimited Speed float Range 0 0 unlimited 我只想要这个数字的
  • 如何检查一个元素是否属于一种子类型或另一种子类型?

    刚刚了解了 Ada 中的枚举和类型 决定写一个小程序来练习 with Ada Text IO use Ada Text IO with Ada Integer Text IO use Ada Integer Text IO procedur
  • Ada 中类型/包别名的单独声明

    我想声明一些 用户定义的编译器常量 以使我的规范文件尽可能保持 常量 这在 C 中很常见 例如 misc config hh namespace misc typedef std shared ptr a A ptr namespace a
  • Ada GPS IDE 似乎找不到 GtkAda

    我已经安装了 GNAT 编程工作室 GPS 和 GtkAda 它们似乎都工作正常 但是当我尝试在 从模板新建项目 下构建简单窗口项目时 我收到一堆错误 提示 文件 gtk ads 未找到 这似乎是一个目录 依赖性问题 GPS 不知道在哪里寻
  • 如何使用“单独”关键字

    我无法找出关键字separateAda 及其深度概念 请举个小例子帮助我理解 假设我有一个嵌套过程 with ada text io use ada text io procedure main is procedure proc is b
  • ADA 文件名与包名称

    我继承了一个 ADA 程序 其中源文件名和包文件名不遵循默认命名约定 ADA 对我来说是新的 所以我可能会错过一些简单的东西 但我在 GNAT Pro 用户指南中看不到它 这个类似的问题 https stackoverflow com qu
  • Ada.Containers.Functional_Maps 在 Ada2012 中可用吗?

    有关的信息Ada Containers Functional Maps https docs adacore com gnat rm docs html gnat rm gnat rm the gnat library html ada c
  • C++ 中的 Ada 子类型等效项

    C 是否提供类似于 Ada 的功能subtype缩小类型 E g type Weekday is Monday Tuesday Wednesday Thursday Friday Saturday Sunday subtype Workin
  • 使用 SPARK 证明选择排序算法

    我试图证明我在 Ada 中的选择排序实现是正确的 我尝试了一些循环不变量 但使用 gnatprove 只能证明内部循环的不变量 package body Selection with SPARK Mode is procedure Sort
  • 创建不兼容的数字子类型

    在 Ada 中 可以创建不兼容的等效数字类型 type Integer 1 is range 1 10 type Integer 2 is range 1 10 A Integer 1 8 B Integer 2 A illegal 这可以
  • 在 Ada 中立即开始循环的下一次迭代

    我想要一个无限循环 其中循环几乎贯穿整个程序 并且在任何时候 基于条件语句 我希望它退出循环的特定迭代并返回到顶部并执行 有办法做到这一点吗 它不必是无限循环 它可以是一个for循环 我只想让它进入该循环的下一次迭代 您可以使用 goto
  • 从 Ada 代码构建静态库,无需 GNAT 即可链接

    我正在尝试从 Ada 代码创建一个静态库 该库可以与一些 C 代码链接 而无需使用 GNAT 工具进行最终链接 我的用例是 我正在尝试将一个用 Ada 编写的库交付给一个为嵌入式目标构建的 C 代码库 为目标构建最终二进制文件的工具链不包含
  • 如何在 Ada 中直接访问内存地址?

    所以我是 Ada 的新手 我正在尝试在其中编写内核 但我似乎找不到任何关于如何正确执行此操作的好信息 在 C 语言中 我会这样写 unsigned char videoram char 0xB8000 videoram 0 65 直接访问视
  • Ada:如何解决“循环单元依赖”?

    假设我有两条记录 Person and Animal 每条记录都在一个单独的包中 包人 with animals use animals package persons is type person is record animalref

随机推荐

  • 无法从字符串表示形式创建“System.Object”类型的对象

    我和 Webforms 解析器今天遇到了一些关于控件属性的困难 我希望你们中的一些人可以帮助我 我有一个Control具有名为 Value 的属性object作为类型 每次我在 aspx 中声明它时都会收到错误 无法从字符串创建 Syste
  • Facebook 身份验证 + 负载均衡器

    因此 我发现这里只有一个其他线程考虑到这个问题 不幸的是它有 1 个答案 0 个赞成票 我的问题是我当前维护的网站使用omniauth gem 通过facebook API 对新用户和现有用户进行身份验证 当我们切换到使用两台服务器 使用相
  • 如何编写一个可以与 Node.js、RequireJS 一起使用以及不使用它们的模块

    我正在开发一个 JavaScript 库JSON XML 处理 https github com highsource jsonix 我的库可以在浏览器和 Node js 中运行 使用xmldom and xmlhttprequest模块
  • Laravel API 控制器结构?

    用户 api 的控制器结构中哪一个有意义 每个 api 版本都有单独的 UI 和 API 控制器 app controllers UsersController php app controllers api v1 ApiUsersCont
  • 从 VisualStudio 2005 升级到 2010(对于 WinForms 项目)是否容易/安全?

    我的团队使用 win forms 和 Visual Studio 2005 为我们的项目构建了许多工具 我们正在考虑升级到 VS 2010 只是想了解任何兼容性问题以及升级的任何好处 升级是否需要花费大量时间和精力 或者 Visual St
  • 如何设置环境变量以便NDK中的CMakelists.txt可以访问?

    使用 NDK 构建 Android 应用程序时 我需要设置一个环境变量 以便 NDK 项目中的所有 CMakeLists txt 文件都可以访问该值 我很可能只需要为这个特定的应用程序设置该值 有直接的办法吗 我尝试过的事情 我尝试过使用
  • Python NUMPY HUGE 矩阵乘法

    我需要将两个大矩阵相乘并对它们的列进行排序 import numpy a numpy random rand 1000000 100 b numpy random rand 300000 100 c numpy dot b a T sort
  • 扫描/线性调频信号以不正确的频率结束

    我正在使用 matlab 倍频程创建扫描 线性调频信号 而我的结束信号似乎以错误的频率结束 我该如何修复它以使信号以正确的频率结束 PS 我无法在八度音阶中使用线性调频命令 因为我正在使用特定方程创建线性调频 扫描信号 带有简单方程的示例代
  • 使用 GET 参数(例如 ?blah=)时,Apache 重定向 301 失败

    我为一位客户构建了一个新的 PHP 网站 并希望将排名靠前的 Google 结果从旧网站结构重定向到新网站结构 我已经在文档根目录的 htaccess 中放置了几十个重定向 301 虽然其中一些工作正常 但其他一些却遇到了问题 这工作正常
  • 使用 serde 生成漂亮的(缩进的)JSON

    使用serde json https github com serde rs json板条箱 我可以用 serde json to string obj 将对象序列化为 JSON 字符串 生成的 JSON 使用紧凑格式 例如 foo 1 b
  • ServerSocket 是否接受任意端口上的返回套接字?

    关于 java 中的服务器套接字 我见过许多与此类似的答案 假设您有一台服务器 其端口 5000 上有服务器套接字 客户端 A 和客户端 B 将连接到我们的服务器 客户端 A 在端口 5000 上向服务器发送请求 客户端 A 端的端口由操作
  • 如何在 scikit-learn 中实现多项式逻辑回归?

    我正在尝试创建非线性逻辑回归 即使用 scikit learn 的多项式逻辑回归 但我找不到如何定义多项式的次数 有人尝试过吗 多谢 为此 您需要分两步进行 让我们假设您正在使用 iris 数据集 因此您有一个可重现的示例 from skl
  • 在 Azure Powershell 任务中使用 Azure CLI

    我想创建一个 Powershell 脚本来执行一些AzureRm 命令并遵循一些命令Az命令 原因是某些命令只能通过Az 当尝试在发布管道中执行这些脚本时 脚本总是失败并出现以下错误 ERROR Please run az login to
  • 路由器页面中的 NodeJS socket.io

    我有 app js 代码 var express require express var app express var server require http createServer app var io require socket
  • 如何将键值对插入到字典的指定位置?

    如何在从 YAML 文档加载的 python 字典中的指定位置插入键值对 例如 如果字典是 dict Name Zara Age 7 Class First 我想插入元素 Phone 1234 before Age and after Na
  • 正则表达式 - 查找所有不以特定前缀开头的匹配单词

    如何构造正则表达式来查找以字符串结尾但不以字符串开头的所有单词 例如查找以下句子中所有以 friend 结尾但不以 girl 开头的单词 A 男朋友 and 女朋友获得了friend当他们要求befriend them 中的项目bold应该
  • 在 NextJS 中添加自动单位的 Google Ads 代码

    我正在开发一个 nextjs 项目 我必须实现用于自动广告的 google AdSense 代码 所以 我的谷歌广告代码就是这样的 没有特定的广告单元代码 根据此脚本加载 Google 将自动添加广告 在这种情况下 我将如何在我的 Next
  • 通过 Torque 将 Julia 文件提交到集群时导入 PyPlot 时出现问题

    我正在学校的集群上运行一些 Julia 代码 调用 test julia jl 的 bps 文件如下 1 bin tcsh 2 3 PBS l walltime 24 00 00 4 PBS l nodes 1 ppn 1 5 PBS N
  • Haskell $ 运算符是否存在逆操作?

    一个简单的问题是 Haskell 中是否有一个运算符 其工作方式类似于美元符号 但优先考虑左侧 IE 代替 f x 1 被写成 f x 1 我想把它写成 x 1 f 这纯粹是一个风格问题 我正在按顺序运行一系列函数 如果我可以从左到右编写它
  • Ada - 提出可访问性检查

    我从Github下载了这个程序 https github com raph amiard ada synth lib https github com raph amiard ada synth lib 我尝试了第一个例子 但遇到了一个例外